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 - Rdevs

Pages: [1]
1
Graphics / Re: Help with moving object according to rotation
« on: January 13, 2016, 04:53:12 pm »
It's hard to describe. In best words, it's point that it rotates around doesn't seem to be consistent. For example, when rotated 30 degrees, it moves in that direction as it should, but then when you change the rotation of the object to, say 60 degrees, it goes in a random direction that is not proportional to it's original direction.
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){
                object.rotate(0.5);
        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)){
                object.rotate(-0.5);
        }

        X = speed*sin(object.getRotation());
        Y = speed*cos(object.getRotation());
       

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)){
                object.move(X, Y);
        }
       
 

2
Graphics / Re: Help with moving object according to rotation
« on: January 12, 2016, 08:37:06 pm »
To explain a bit more, what I would like is to replicate the controls of the object you control in the 2d game asteroids, please can someone tell me what I need to do in order to achieve this?  ;)

Update: @Arcade, As above basically I would like the controls to be like the game Asteroids. it doesn't go in the direction I expected when the object is rotated.

3
Graphics / Re: Help with moving object according to rotation
« on: January 12, 2016, 08:14:43 pm »
I see, ok so I changed it to 180, but unfortunately it is not working as it should. I think the rotation of it isn't working properly. When the object is moved linearly, the rotation goes incorrectly. I want the angle to be the rotation around the same point (the center of the object) if you see what I mean.

4
Graphics / Help with moving object according to rotation
« on: January 12, 2016, 07:39:57 pm »
I would like some help with moving an entity in proportion to it's rotation, For example if it is rotated 30 degrees clockwise, I would like it to move in that line from 30 degrees. I know this seems a fairly basic task/problem, but I don't quite know how to do it exactly. I have read a bit on radians and similar, but my code below doesn't seem to work correctly. This is the closest I have got to it working, but I want it to move in the same linear direction, and when you rotate it, it works correctly.


//convert the angle of the object to radians
radians = 3.1415926536 / 360*object.getRotation();

//x and y
x = 0.5f*cos(radians);
y = 0.5f*-sin(radians);
//rotate accordingly
object.move(x, y);

 

Pages: [1]