Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - oOhttpOo

Pages: [1] 2 3
1
General / Re: Draw text with OpenGL?
« on: May 25, 2015, 10:25:32 pm »
Reading your past posts it's evidently clear that you're missing a lot of basic programming and C++ knowledge, so I strongly recommend you don't try to do anything OpenGL, but instead learn some basics and get a simple game or similar done.

And yes you need the graphics module with render window to draw text with SFML.

Well that's where you're very wrong. I have far more experience than you think. Why post at all if you are not even going to attempt to help about the issue?

2
General / Draw text with OpenGL?
« on: May 25, 2015, 09:39:49 pm »
I'm trying to draw 2D text in a sf::window so that I can use OpenGL in it too, but you (correct me if i'm wrong) can only draw with render windows. Is it possible to draw stuff in 2D (text etc.) with OpenGL in sf::Window class? Or should I use a different library?  ???

3
General / Re: How to move something to rotation of shape?
« on: May 16, 2015, 09:59:50 pm »
I'll give that a go, thanks  ;)

4
General / Re: How to move something to rotation of shape?
« on: May 16, 2015, 09:55:52 pm »
Sorry for not being clear, I want to move one shape in the direction of another shape's rotation.
So if the rotating shape has been rotated 20 degrees from it's origin, the other shape would move diagonally (to the same direction of the rotating shape).

5
General / How to move something to rotation of shape?
« on: May 16, 2015, 09:31:41 pm »
Is there a way to move a sprite directly to the rotation of another (with getRotation())? The only way I can think of is to move it in a certain movement for when the other sprite is at every certain rotation, but surely there must be a much simpler and easier way? I tried:
shape1.move(shape2.getRotation());
 

6
General / Re: Help with changing a sprite direction
« on: May 15, 2015, 08:48:46 pm »
In my first game I made, I made shapes rebound off walls with simply:


... // Make the shape bounce

if (!boundingbox.intersects(boundingbox2))
{
shape1.move(0, 0.1);
}
 
Hope this helps  :)

7
Graphics / Re: Movement and origin help
« on: May 15, 2015, 08:28:42 pm »
Sorry my bad, I meant to put (200, 2.5) for setOrigin. Long day  :P Have had no success with what shadowmouse has suggested though.

8
Graphics / Movement and origin help
« on: May 14, 2015, 09:46:44 pm »
Hi
In a game I'm making, for one object, it has to rotate when triggered, but it's a bit complicated.  Basically I don't know how to rotate the shape from it's centre with setOrigin, because I have already used it. My code probably explains it better... Perhaps there is an easy solution to this?

 

shape1.setOrigin(-100, -375);

...
window.clear(sf::Color::Cyan);

si.setPosition(shape2.getPosition());
...
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
shape1.rotate(0.1); //need to rotate it from it's centre (x/2, y/2)
}

 

9
Graphics / Set position depending on another entity
« on: May 12, 2015, 09:04:31 pm »
Hi

I want to set the position of a shape to the same (or roughly the same, doesn't really matter) position of another shape. However I cant just do .setPosition(points) as the shape is often moving, therefore I would like to set it to same position as the other shape (every time it is triggered). I tried to set the position to the other shape's global bounds. I attempted "shape1.setPosition(shape2gbs)". How can I do this?  ;)

10
General / Re: Entity origin irrelevant to rotation
« on: May 09, 2015, 04:05:54 pm »
I fixed it now thanks  :)



11
General / Re: Entity origin irrelevant to rotation
« on: May 08, 2015, 07:50:40 pm »
Thanks for the responses, but I unfortunately came to no solution. Here's the code cut down the best I could:

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <iostream>
#include <Windows.h>
using namespace std;
#include <time.h>


bool targethashit = false;
bool gunfire = false;
bool leftisclicked = false;


int main()
{
        sf::RenderWindow window(sf::VideoMode(600, 600), "Window");

        sf::RectangleShape hill1(sf::Vector2f(200, 200));
        sf::RectangleShape hill2(sf::Vector2f(200, 400));
        sf::RectangleShape hill3(sf::Vector2f(100, 500));
        sf::RectangleShape hill4(sf::Vector2f(200, 100));
        sf::RectangleShape sniper(sf::Vector2f(20, 40));
        sf::RectangleShape snipergun(sf::Vector2f(50, 3));
        sf::RectangleShape bullet(sf::Vector2f(15, 3));
        sf::RectangleShape target1(sf::Vector2f(10, 10));

       
        sf::RectangleShape si14(sf::Vector2f(20, 5)); //create the entity i need to rotate





        bullet.setOrigin(-40, -375);
        target1.setOrigin(-550, -296);


        si14.setOrigin(-490, -375);                                      //set the origin of the entity i need to rotate
        si14.setFillColor(sf::Color::Green);


        bullet.setFillColor(sf::Color::Yellow);
        sniper.setOrigin(-30, -360);
        snipergun.setOrigin(-40, -375);
        hill1.setOrigin(0, -400);
        hill2.setOrigin(-150, -300);
        hill3.setOrigin(-350, -200);
        hill4.setOrigin(-450, -500);
        hill1.setFillColor(sf::Color::Green);
        hill2.setFillColor(sf::Color::Green);
        hill3.setFillColor(sf::Color::Green);
        hill4.setFillColor(sf::Color::Green);
        snipergun.setFillColor(sf::Color::Black);
        sniper.setFillColor(sf::Color::Red);

        while (window.isOpen())
        {


                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();

                }


                window.clear(sf::Color::Cyan);


               
         window.draw(si14);
       

       
                sf::FloatRect bulletb = bullet.getGlobalBounds();
                sf::FloatRect target1b = target1.getGlobalBounds();
               
                window.draw(snipergun);
                window.draw(sniper);
                window.draw(target1);
               
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
                {
                        sniper.move(0.1, 0);
                        snipergun.move(0.1, 0);
                        bullet.move(0.1, 0);
                }

                si14.rotate(-0.1);
                }

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
                {
                        sniper.move(0, -0.5);
                        snipergun.move(0, -0.5);
                        bullet.move(0, -0.5);
                }
               
                if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
                {
                        si14.rotate(0.1);                                                                                                                       //it only rotates from the top left corner
                }
                       
                       
       
                       

                window.display();



        }
        return 0;

}

12
General / Re: Entity origin irrelevant to rotation
« on: May 04, 2015, 11:27:40 am »
How would -100, -300 ever be the center?
That's the shape position I need it to have. I also experimented with -300, -300 as such but it still rotates from the corner. To clarify I need the shape to rotate around it's own center (around -100, -300). I simply don't know how you do this  ;)

13
General / Entity origin irrelevant to rotation
« on: May 03, 2015, 09:55:12 pm »
I'm experiencing a problem with rotating a rectangle shape, I need it to rotate around the center of the rectangle, not the top left corner by default. However I have done .setOrigin(-100, -300), yet when I do .rotate(0.1) it still rotates from 0, 0 (the default, top left corner). I can't get my head round this, any ideas? It may be difficult to upload the relevant parts of my code, as my code is very large.

14
Audio / Re: Sample volume of audio file every second?
« on: April 27, 2015, 11:03:47 pm »
The class or whatever it is. Some people are just so satirical with their posts they might of just not bothered to respond instead of actually trying to help. I'm not wasting anymore time going on this stupid forum, bye

15
Audio / Re: AW: Sample volume of audio file every second?
« on: April 27, 2015, 05:27:55 pm »
Look at the audio tutorials and documentation. Everything that is possible is explained there.

Programming is about solving problems. If you have to rely on others to solve any problem for you, you'll have a really hard time.

Righto. Is it possible to do this with the getSound function? I mean like once every 100 milliseconds or something

Pages: [1] 2 3
anything