Advertisement

i need help with a 2d space shooter....

Started by October 08, 2002 03:57 PM
2 comments, last by pyro1245 22 years, 4 months ago
i am trying to make a 2d, top-down space shooter. i cant come up with a good way to get the ship to move at different angles after it gets rotated. for example, if i rotate the ship to a misc. angle, how do i make it move in the right direction when i hit the thrusters? i hope i explaned that good enough. can anyone help me? thanks [edited by - pyro1245 on October 8, 2002 5:33:41 PM]
I used the following approach to exactly this problem:

I gave the ship an int value called angle which is increased or decreased with left & right, and is set back to zero if it grows larger than 360 and viceversa. You can determine what direction angle zero is facing, I chose right. Then a switch determines several thresholds for what general direction the ship is pointed and what it''s vector should be. Any velocity is applied to the vector. Also, the switch sets another int which is the index in the array of the ships animation set, so you can decide how many directions you want to have drawings for. I don''t know how to do mode 7 rotations, so that''s the best thing I could come up with. Hope this is of some use.
Advertisement
thanks for your help, Jubilant
You could also find a "rise" and "run" by taking the angle and velocity and using sin() and cos().

example 1:
a = 55
v = 70
Xvel = cos(55)*70 = 40.15
Yvel = sin(55)*70 = 57.34

example 2:
a = 235
v = 15
Xvel = cos(235)*15 = -8.603
Yvel = sin(235)*15 = -12.287

This topic is closed to new replies.

Advertisement