This project has moved and is read-only. For the latest updates, please go here.

Quick Question: Resolution

Aug 16, 2008 at 1:53 AM
Edited Aug 16, 2008 at 2:01 AM

I'm rewriting this post.

My question is, is it possible to scale resolutions? If someone has the game set to 1024x768, and someone else has it set to 1600x1200, it scales all the objects on screen to a specific size, so that the game doesn't break or anything like that?

Aug 16, 2008 at 4:13 AM
Realizing this isn't much to do with the physics engine, I'd like to delete this post, but oh well.
The answer I found was to use a scale matrix in the SpriteBatch begin method, but I'm having trouble figuring out a universal equation for scaling resolutions to a default one.
Aug 16, 2008 at 5:39 AM
The matrix in .Begin() scales everything drawn. This does not apply to physic objects. I don't know if you use Farseer (I think you do since you post here :) ) so you should scale your physics objects too.

If you have polygon objects, you can use the following code to scale them:

        public static void ScaleVectors(ref Vertices vertices, Vector2 scale)
            for (int i = vertices.Count - 1; i >= 0; i--)
                vertices[i] *= scale;

I've created a sprite class that contains a texture, color, scale and the like so I can scale every element on the screen individually. This way the borders in the game (Screen borders so that the player don't fall out of the screen) can be the same size in all resolutions but the player character and other objects are scaled for the resolution.

I've designed my games for the 800x600 resolution, if someone has 1024x768 I do this:

Y= NewY/OldY

X=1024/800 (gives 28% increase in scale)
Y=768/600 (gives 28% increase in scale)

So if your object is 200x200 it would become 256x256 in size.
Aug 17, 2008 at 7:45 PM
That would change the game slightly though, people would be getting less Colision Errors if they use the bigger one... Is there some way to make the Image on screen scaled rather thn the whole game objects?