Original Post
Im currently working on getting a small top down game working. At this point, i can draw this little tank on the screen and can drive it whereever i want to on the screen. But im running into something a little strange. Right now, if i move my object to the left side of the screen, i notice that my X value is getting larger, as if it were going up the positive scale, and if i go to the right, the x is getting smaller for some reason. Obviously this is the opposite of a standard axis. Then i noticed that in my move functions, I am infact decreasing the value to go 'forward'.(taking from a tutorial that i now cant find). but im not sure why its works this way. I as thinking maybe its my view matrix, but if i move it to where it works with the axis, all the images are flipped upside down. If anyone can lend a hand, I would be extremely thankful. Here are some exerts from my code. How the projections and view matrices are setup. Acceration calls and functions Transforms and drawing
device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, this.Width / this.Height, 0.3f, 500f);
device.Transform.View = Matrix.LookAtLH(new Vector3(0, 0,30), new Vector3(0, 0, 0), new Vector3(0, 1, 1));
if (keys[Key.UpArrow])
{
tank.accelerate(-.1f);
}
if (keys[Key.DownArrow])
{
tank.accelerate(.05f);
}
//further down in the accelerate function
public void accelerate(double x)
{
this.x += (float)(x * Math.Cos(a));
this.y += (float)(x * Math.Sin(a));
}
device.SetTexture(0, tank.getTexture());
tank.translation_matrix = Matrix.Translation(tank.x, tank.y, 0.0f);
tank.rotMatrix = Matrix.RotationYawPitchRoll(0.0f, 0.0f, tank.getAngle());
tank.result = tank.rotMatrix * tank.translation_matrix;
device.Transform.World = tank.result;
device.DrawUserPrimitives(PrimitiveType.TriangleList, 2, tank.draw_tank());