PDA

View Full Version : Question about movement in 2D games



Bluebomber357
10-01-2009, 08:00 PM
If I was to make a 2D game, and I wanted to move something says two pixels to the left when I hit the left arrow key, that will move the object a different distance on the screen depending on the resolution of the program. Is it naive to move objects by pixel lengths? Should I be creating units of length based on the height and width of the resolution?

MarkS
10-01-2009, 11:35 PM
Look into time-based animation. It is far superior to a strictly pixel-based movement algorithm.

zeoverlord
10-02-2009, 05:47 AM
Should I be creating units of length based on the height and width of the resolution?
no, you set up the projection matrix so that it is exactly the same no matter the resolution.

Bluebomber357
10-02-2009, 09:03 AM
If I use a projection matrix, does it have to be as high as my highest resolution? Like say 1080p?

zeoverlord
10-02-2009, 03:07 PM
no it could be anything like 100x100

Bluebomber357
10-02-2009, 04:14 PM
Yeah but if I use 100x100, then won't my movement be really jerky if I run the game at fullscreen on a 1080p monitor. For every 10.8 pixels I move in the drawing area, I'll only move once in the viewport, and I can only move to 100 locations in the y-direction on the viewport right?

zeoverlord
10-04-2009, 12:14 PM
no it's float values so you can use 45.835735f if you like