Correct way to scale the game

BlitzMax Forums/BlitzMax Programming/Correct way to scale the game

Ravl(Posted 2014) [#1]
Hi all,

I wanted to ask you which is the correct way to scale the whole screen of the game?

Let's assume I make the graphics for my next adventure game in HD resolution: 1280 x 720 and the user pc supports FULL HD: 1920 x 1080.

On Windows would be very simple to setup the graphics to 1280 x 720 (in full screen) but on Mac OS this is not possible so I was thinking how about to keep the screen resolution and scale my graphics.

I made this little test:

currentResX and currentResY are the screen current resolution before starting the graphic device.
Local scaleX:Float = currentResX / 1280
Local scaleY:Float = currentResY / 720


and in the Main Loop:


SetScale(scaleX, scaleY) 'we setup the scale 1st time

Repeat
	Cls
		If KeyDown(KEY_ESCAPE)
			EndGraphics
			End
		End If
			
		DrawImage(imageBackground, 0, 0)		
		DrawText("Scale Test", 50, 100)
	Flip
Forever


Basically it's working fine. Of course I will have to make my mouse click checks according to the scaleX and scaleY.

So, is there any other way to do this? It's this correct?

Thanks,


Derron(Posted 2014) [#2]
Have a look at this:
http://www.blitzbasic.com/codearcs/codearcs.php?code=2879


bye
Ron


ImaginaryHuman(Posted 2014) [#3]
Typically you will decide to `lock` one of the two dimensions, such as the height. So for example you might say your display height always represents 720 units in game coordinate space. Then when the resolution changes, it still represents 720 units (use the virtual resolution stuff)... Then you can calculate the horizontal size based off the ratio of the vertical size compared to the original 720. That's how it's done in Unity for example.


Ravl(Posted 2014) [#4]
@Derron: that is more than I wanted it, thanks.