Sunday 27 September 2009

Camera working!

Ok guys so I haven't being doing much game programming lately. I have been busy building up my website.

Although tonight I have managed to get my camera working. I did this by using matrices. Firstly I created a camera rotation matrix using the following lines


Matrix rotationMatrix;
            Matrix.CreateRotationY(MathHelper.ToRadians(cameraYaw), out rotationMatrix);

as you can see I first initialize the matrix using Matrix rotationMatrix then I go onto create a value for how much I would like to rotate. cameraYaw is a const variable set to 2.0f.

and using input I then determine whether or not I would like to set this rotation matrix into effect.
Like so...


    if (keyboardstate.IsKeyDown(Keys.D))
            {
                cameraYaw -= spinRate;
              
            }

So thats all working. Now I am going to work to make it so that the camera goes in the direction of the target. Hopefully that shouldn't be to hard.

Anyway once I get that up and running I will definitely get some missiles firing. I have decided that since this is my first 3D game I am not going to go into to much detail and just get the thing finished. For instance I was going to split the tank model into 2 models so that I could rotate the top of the tank like a turret on a real tank would but that would be too much work. And I am probably going to change the model again as I am not quite happy with it. Anyway right now the missiles will only fire towards whichever direction the tank is facing.

After getting this set up I will find a way to make the terrain solid. And set up some collision boxes around the tank and the terrain. Having done this I will find a way to add gravity to my game to make sure that my tank is constantly on the ground :D

Anyway back to work!

No comments:

Post a Comment

money maker