How does resolution work?

Hi there,

I was curious about how exactly resolution and scale works on games. If you program with a certain coordinate, how can you make it so that at fullscreen, the game still looks the same. Or rather than fullscreen, some other set of ratios on the same 16:9 ratio scale.

Thanks!

  • A

More or less tech-agnostic answer:

If all your coordinates are in a coordinate space defined by a rectangle C1:
[icode]Origin: (0, 0) Width: w1 Height: h1[/icode]

Then to transform to a different coordinate space C2 defined by:
[icode]Origin: (0, 0) Width: w2 Height: h2[/icode]

you do this:

double scaleX = w2 / (double)w1;
double scaleY = h2 / (double)h1;
Point transformed = new Point(original.x * scaleX, original.y * scaleY);

To be clear, this is to “stretch” (or shrink) C1 to fit C2. This may not be what you want.