Code archives/Graphics/2D Multiple Resolution Helpers

This code has been declared by its author to be Public Domain code.

Download source code

2D Multiple Resolution Helpers by Jeremy Alessi2004
It's pretty simple. There are plenty of times when you want to position some regular 2D text on screen and have it fit right in all resolutions.

;Moves mouse to this position relative to a 640 X 480 display, will keep things in order at higher resolutions without needed to plot different points.
MoveMouse(CorrectX(340),CorrectY(452))


;Draw the text on the left side of the screen always, but adjust the vertical to be about the 40th pixel in a 640 X 480 display.
Text(0,CorrectY(40),"Keep it up!")


It's really simple but effective.
;====== CORRECTX ==========================================================

Function CorrectX(pixel)
	
	Return ( pixel * GraphicsWidth() / 640 )

End Function

;==========================================================================

;====== CorrectY ==========================================================

Function CorrectY(pixel)
	
	Return ( pixel * GraphicsHeight() / 480 ) 

End Function 

;==========================================================================

Comments

None.

Code Archives Forum