New resolution, new velocity?

Started by
3 comments, last by rlange 16 years, 9 months ago
So I have a 2d tank game. The game allows the player to choose 8 different resolutions, 4 wide & 4 standard. Once in the game all the textures and velocities are multiplied by a scale factor determined from the resolution the game art was designed for VS the one being played. This works just fine for everything I’ve run across, until now. When a tank fires a bullet I use a float for the velocity because if the position vector had different multipliers for the X/Y directions it wouldn’t hit the intended crosshair position. The time it takes a bullet to reach from 0,0 to screen.x,screen.y needs to be the same on all resolutions to make multiplayer possible. So the question would be; how do I determine the scale (float) to multiply the default velocity (float) by to make all this possible? I could just use the vector2 scale.x as the multiplier if I just supported wide or standard... I suppose the answer involves another multiplier if it’s wide (1.6) vs standard (1.3)… Anyway, it’s late and the answer might hit me in the morning so please leave all the helpful hints you have. Rob [Edited by - rlange on July 11, 2007 3:12:08 AM]
Advertisement
Keep all your game units the same! Only scale when you are rendering to the screen.
I think you can avoid any kind of scaling by using an orthographic projection. For example, you can make the screen 640x480 *UNITS*, not pixels, and then it won't matter what resolution you're using.
Quote:Original post by umbrae
Keep all your game units the same! Only scale when you are rendering to the screen.


Quoted for emphasis. If you ever heard the advice (and if you haven't, here it is) to keep rendering code and game logic separate, this is one of the reasons why.
Thanks guys. It was a lot easier to scale the mouse position down to game units than try to scale everything up to pixels. I just had to divide the mouse position and then in the rendering code make sure that I scaled the position as well as the already scaled texture size.

Thanks!

This topic is closed to new replies.

Advertisement