Advertisement

Tank game. Help with rotation please!!!

Started by May 27, 2002 11:11 PM
0 comments, last by shoryuken 22 years, 8 months ago
I am newbie at game programming. I have read many other posts similar to this, but just not what I was looking for, or maybe I just didn''t understand it. Ok, my problem is simple. I am trying to make the very oh so popular tank game. I have position and velocity vectors for the tank. I want to be able to rotate it, and move it forward and backward. How do I do this? I think I need a vector to specify which direction is the front of my tank. But other than that, I have been thinking about this for two days now, and have no idea how to do this. I realize this may seem like too simple a problem to require that much effort, however, I am fairly dumb. Like, how do I rotate the forward vector, in the case that I have one. How do I move my tank back and forth along that vector? Any help would be very very very much appreciated. Thank you. u can also email me: glubberblubber@hotmail.com or IM me AIM: SumKungFuDude
Given a position, and a rotation, you can generate a matrix for the tank:

mRot = MatrixRotationYAxis(fTankRotation)
mPos = MatrixTranslation(vTankPos);
mTank = mPos*mRot

Now, from this matrix you can extract the Z Vector (it''s either 3rd Column, or 3rd Row, depending on whether you''re using OpenGL or DirectX).

Allan
------------------------------ BOOMZAPTry our latest game, Jewels of Cleopatra

This topic is closed to new replies.

Advertisement