Moving on a cartesian coordinate system
Lets say I have a cartesian coordinate system. The players ship ( overhead view ) starts off at the center of the screen.
The variables int PlayerPosX and int PlayerPosY are declared as is PlayerAngle which represent the angle of the ship. When the player hits the left and right arrow keys the angle changes and the bitmap is rotated fine. But when the up arrow key is hit, I went to ship to move in the direction it is facing. I have approached this problem from various angles but without ever succeding.
I have tried one approach where the Xspeed and Yspeed variables where used to increment PlayerPosX and PlayerPosY, but I dindt find the right equation.
Does anyboady knows of some pseudo-code/equation/way to do this ? Anyway ?
WHO DO THEY
THINK THEY''RE
FOOLING : YOU ?
WHO DO THEYTHINK THEY'REFOOLING : YOU ?
This is just trigonometry (bad spelling, probably )
If you have an angle a, and a speed s, then the velocity in the x direction is
s*Cos(a)
and for the y, it is
s*Sin(a)
I could draw an ASCII diagram, but it''d probably end up looking funny, but those are the formulae you need.
I might have missed something, but these should get you going.
If you have an angle a, and a speed s, then the velocity in the x direction is
s*Cos(a)
and for the y, it is
s*Sin(a)
I could draw an ASCII diagram, but it''d probably end up looking funny, but those are the formulae you need.
I might have missed something, but these should get you going.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement