# Resolution independent physics

| | August 10, 2015

I’m making a game like Doodlejump but don’t know how to make the physics scale on multiple resolutions. I also can’t find anything related to this on Google. Right now I’m scaling the game using letterboxing and tested scaling the jump height with this code:

``````gravity = graphics.getHeight() * 0.001f;
jumpVel = graphics.getHeight() * -0.04f;

...

velY += gravity;
y += velY;
``````

But if I test this on my smartphone or emulator with different resolutions, I always get a slightly different jump height. I know that Farseer is resolution independent. How can I replicate this in my game?

## One Response to “Resolution independent physics”

1. You don’t scale your physics. Your physics should be based in an arbitrary coordinate system, completely independent of the device.

Then when you do your drawing, you translate your “physical” location to a screen location based on the screen resolution. You need to calculate the scaling amount based on the screen resolution.

For example, if you define your arbitrary world size as 1200 “units” wide, then on a device with a 1920 pixel wide screen, your view scale is: 1920/1200 = 1.6

So for example, gravity and jump velocity would simply be:

``````gravity = 0.001f;
jumpVel = -0.04f;

viewScale=graphics.getWidth()/WORLD_WIDTH;
``````

Then when you draw your object, you’d use:

``````screenX=worldX*viewScale;
screenY=worldY*viewScale;
``````
• ### How To Submit a iPhone App to the Appstore

by on July 5, 2012 - 0 Comments

The process to develop an iPhone app is not as hard as one might think. The entry into the app store has been opened up to many new types of develope...

• ### Develop iphone Apps on Windows

by on March 7, 2011 - 13 Comments

Top 10 Ways to Develop an iphone/ipad app without a Mac #1. Code in Java For Java developers, there is a workaround: XMLVM. XMLVM cross-compiles byte...

• ### Iphone Android App Ideas: Getting Started

by on March 19, 2011 - 3 Comments

Smartphone Application Ideas: Getting Started Smartphone application developers are constantly on the move. And since overzealous developers stick ...