Sign in to follow this  
rlange

New resolution, new velocity?

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this