Can i do some stuff with angles? (in vc++ 6.0 off course)
Hello again...
the question is: how can i turn an object by hitting the left or right button. I want to create something like a moving car, i have the forward and backwards but the turning is a problem. Well a problem, i simply don''t know. Anybody?
Sig
January 13, 2000 07:57 PM
wow, i need more details than that...
are you talking about 2d tile engine with a moving car, or a 3d engine ?
from your title i see you tried angles,
i think angles is not the right approch, what you need is Vectors.
Me and my friend did a car game on tile-engine and this is how we did it:
In a 2d engine your car would have a speed vector defined by two floats (vx,vy). its length would be how fast the car is going. for example each second the car would move from x to x+vx and from y to y+vy. to increase the speed you multply both vx and vy by more than one (lets say 1.1) and to decrease you multply both by less then one (0.9). TO TURN AROUND all you''ll have to do is rotate the speed vector. If you dont know vector math yet then you can define the vector with an angle and a radius and calculate vx and vy with Trig,(cos and sin). If you dont know Trig dont expect your car to turn...
If you are thinking 3d its all the same but with a vZ. but for 3d you shouldnt even try trig, get a math book and learn matrices and vectors...
are you talking about 2d tile engine with a moving car, or a 3d engine ?
from your title i see you tried angles,
i think angles is not the right approch, what you need is Vectors.
Me and my friend did a car game on tile-engine and this is how we did it:
In a 2d engine your car would have a speed vector defined by two floats (vx,vy). its length would be how fast the car is going. for example each second the car would move from x to x+vx and from y to y+vy. to increase the speed you multply both vx and vy by more than one (lets say 1.1) and to decrease you multply both by less then one (0.9). TO TURN AROUND all you''ll have to do is rotate the speed vector. If you dont know vector math yet then you can define the vector with an angle and a radius and calculate vx and vy with Trig,(cos and sin). If you dont know Trig dont expect your car to turn...
If you are thinking 3d its all the same but with a vZ. but for 3d you shouldnt even try trig, get a math book and learn matrices and vectors...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement