# Need help with strange problem

This topic is 4440 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.
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));

Acceration calls and functions
  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));

}


Transforms and drawing
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());



##### Share on other sites
Is there a reason, why the "Up"-Vector of your world points to (0,1,1)?

Try to set it to the y-axis, like this:

device.Transform.View = Matrix.LookAtLH(new Vector3(0, 0,30), new Vector3(0, 0, 0), new Vector3(0, 1, 0));

*edit*

And additionally, your "eye" is at 0,0,30 along at your z-axis and you are looking back at 0,0,0.

Is that what you wanted?

HTH

1. 1
Rutin
34
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633341
• Total Posts
3011424
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!