   Tank Movement
  I know this is probably me doing something stupid but I am trying to make a tank move in an openGL game. So left and right arrows turn it and forwards and backwards move in in the direction it is facing, the main movement is from:if(0 <= spintrig && spintrig >= 90){movex = sin(spintrig)*testpos;movez = cos(spintrig)*testpos;}else if(90 < spintrig && spintrig >= 180){spintrig2 = spintrig-90;movex = sin(spintrig2)*testpos;movez = -cos(spintrig2)*testpos;}else if (180 < spintrig && spintrig >= 270){spintrig2=spintrig-180;movex = -sin(spintrig2)*testpos;movez = -cos(spintrig2)*testpos;}else if(270 < spintrig && spintrig >= 360){spintrig2=spintrig-270;movex = -sin(spintrig2)*testpos;movez = cos(spintrig2)*testpos;}glTranslatef(movex,0,movez);glRotatef(spin,0,1,0);drawTank();With the keys controlling from:if(keys[VK_UP]){testpos += 1;}else if(keys[VK_DOWN]){testpos -= 1;}if(keys[VK_LEFT]){spin+=0.2;spintrig+=0.2;}else if(keys[VK_RIGHT]){spin-=0.2;spintrig-=0.2;}}void update(){spin += speed;if(spin > 360)spin = 0;if(spintrig > 360)spintrig = 0;}Basically I worked out that if the angle of movement is between 0-90 the Z movement and X movement will be both positive, if the angle is between 90 and 180 it will move between the negative Z and positive X axis and so on.The rotation works fine but my tank does not move at all. Anyone know what could be wrong?Oh and the sin and cos bits are just me working out the x and z counterparts of the movement. I am using x and z as I am eventually expanding it to 3D. Been a while since I have done it so am starting simple.I tried rotating everything but the tank but it ends up rotating around the origin rather than the tank.   
  Well the code is doing everything you tell it to do, if you actually analyze what you've written you might see the problem.You need to seperate seperate the position and direction.You rotate the direction, and you increase the position by the direction with a scalar for speed to move it.   ;Quote:I am using x and z as I am eventually expanding it to 3D.Just because the simulation is in 3-d doesn't mean you have to use x and z; you can instead use x and y, and make z the vertical axis (which is in fact what I'd recommend for any simulation that has a strong 2-d component).   ;  Also, your if and else if conditions are incorrect.if(0 <= spintrig && spintrig >= 90)is equivalent toif(spintrig >= 90)For a number to be between two values you'll need:if(0 <= spintrig && spintrig <=90)or slightly more readableif(spintrig >= 0 && spintrig <= 90)