View Full Version : Question about movement in 2D games
10-01-2009, 09: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?
10-02-2009, 12:35 AM
Look into time-based animation. It is far superior to a strictly pixel-based movement algorithm.
10-02-2009, 06: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.
10-02-2009, 10:03 AM
If I use a projection matrix, does it have to be as high as my highest resolution? Like say 1080p?
10-02-2009, 04:07 PM
no it could be anything like 100x100
10-02-2009, 05: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?
10-04-2009, 01:14 PM
no it's float values so you can use 45.835735f if you like
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.