Jump to content

  • Log In with Google      Sign In   
  • Create Account


2D wierd movement...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Prod   Members   -  Reputation: 134

Like
Likes
Like

Posted 25 November 2001 - 12:38 PM

I was wondering,(This is in a 2 dimensional view, not 3D) how do you get something to move in the direction its facing? Im making a little space sim, and i want the ship to be able to turn =p. what im trying to accomplish is when i hit VK_UP it will move forward, and the VK_LEFT will turn it left and the VK_UP key will now move the ship the direction i turned with VK_LEFT.

Sponsor:

#2 HellRiZZer   Members   -  Reputation: 308

Like
Likes
Like

Posted 25 November 2001 - 01:02 PM

You have to store the angle of your object angle. E.g if it facing up, then its 90 degrees, right - 0 degrees and so on.
So, when you press ''move forward'', your object will move

x+=xspeed*cos(A);
y+=yspeed*sin(A);

or something like that.
So, when you press left, A+=rotationspeed;
or right A-=rotationspeed;

#3 Prod   Members   -  Reputation: 134

Like
Likes
Like

Posted 25 November 2001 - 03:39 PM

thanks, i will try it out




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS