Iam fooling around with the core percentage system and thinks it is a bit hard to handle.
And i dont like black borders that the original virtual resolution creates.
So i thought i should share it.
The sample show an 320x480 virtual resolution.
rem
rem AGK Application
rem
type sScreen
Width As Float
Height As Float
Aspect As Float
endtype
Global Screen As sScreen
Screen.Aspect = GetDisplayAspect()
REM // This is an target virtual resolution
REM // It will be slightly differrent in various
REM // resolutions,but will be very close.
REM // Tested on ////////////////////////
REM // samsung galaxy y (240x320) = 314x474
REM // zte skate (480x800) = 319x487
REM // dmtech pad (768x1024) = 319x502 (on sandwich so did it also register the static menue field at the bottom 16 pixels/502-16=486 )
REM // pc (480x640) = 319x479
REM // The pixel count starts with 0 thats why 320 is 319 :)
Screen.Width = 320.0
Screen.Height = 480.0
SetDisplayAspect( Screen.Aspect )
global spr
REM // Create an cube 50 pixels high and wide
spr = CreateSprite( 0 )
SetSpriteSize( spr, X (50), Y (50) )
rem A Wizard Did It!
do
REM // Makes the cube bounce around the screen
if dir=0
x#=x#+1.0
else
x#=x#-1.0
endif
if dir2=0
y#=y#+1.5
else
y#=y#-1.5
endif
REM // Check when center of cube leaves the screen
if GetSpriteXbyOffset( spr )> X (Screen.Width) then dir=1
if GetSpriteXbyOffset( spr )< X (0) then dir=0
if GetSpriteYbyOffset( spr )> Y (Screen.Height) then dir2=1
if GetSpriteYbyOffset( spr )< Y (0) then dir2=0
SetSpritePosition( spr, x#, y# )
REM // print screen touch and center off screen data
print(To_PIX_(GetPointerX(),Screen.Width))
print(To_PIX_(GetPointerY(),Screen.Height) )
print( X (Screen.Width/2))
print( Y (Screen.Height/2))
// escape on computer and back button on device
if GetRawKeyState(27)=1 then end
Sync()
loop
Function To_PIX_(nr#,src#)
result#=floor((nr#/100.0)*src#)
endfunction result#
Function To_PRC_(nr#,src#)
result#=(100.0/src#)*nr#
endfunction result#
Function X(nr#)
result#=(100.0/Screen.Width)*nr#
endfunction result#
Function Y(nr#)
result#=(100.0/Screen.Height)*nr#
endfunction result#
Android 2.3 Gingerbread , ZTE Skate , 480x800 , 800 mhz cpu , Samsung Galaxy Y , 240x320 , 832 mhz cpu
Android 4.0 Sandwich , Dmtech 3g 9738B , 1024x768 , 9.7 inches , cortex A8 1.2 cpu , 1 gb ram.