Advertisement

Movement in 2D

Started by November 21, 2002 11:57 AM
1 comment, last by Bluefox 22 years, 3 months ago
Hi, I am trying to do a asteroids clone and just having problems moving my ship in the direction it is facing in. I know about sin and cos and have been playing around with them with little success, and would appreciate help.
from your trig class:

x = r cos theta
y = r sin theta


Advertisement
float angle;   // current bearing, 0 = vertical (x axis), positive clockwisefloat posX;float posY;void move( float distance ){  posX += cos(angle) * distance;  posY += sin(angle) * dishance;} 


This topic is closed to new replies.

Advertisement