I have been trying to change the code to keep the player in the center and scroll the background but i'm not sure where to start. Here is what I have now. Can someone please help?
rem set a virtual resolution of 320 x 480
SetVirtualResolution ( 320, 480 )
AddVirtualJoystick ( 1, 35, 445, 64 )
AddVirtualButton ( 2, 285, 445, 50 )
rem load an image that contains several frames of animation
LoadImage ( 1, "skeleton_walk_001.png" )
CreateSprite ( 1, 1 )
SetSpriteAnimation ( 1, 64, 64, 24 )
SetSpriteDepth ( 1, 0 )
rem top half of pitch
LoadImage ( 2, "pitch_top.jpg" )
CreateSprite ( 2, 2 )
setspritesize (2, 1280, -1)
SetSpriteDepth ( 2, 1 )
rem bottom half of pitch
LoadImage ( 3, "pitch_bottom.jpg" )
CreateSprite ( 3, 3 )
setspritesize (3, 1280, -1)
SetSpriteY ( 3, GetSpriteHeight ( 2 ))
SetSpriteDepth ( 3, 1 )
rem ****************************************************
do
rem move with cursor keys and joystick
mx#=GetVirtualJoystickX( 1 )
my#=GetVirtualJoystickY( 1 )
rem when there is no input stop animation
if ( mX# = 0.0 and mY# = 0.0 )
StopSprite ( 1 )
SetSpriteFrame ( 1, 8 )
else
rem find player position
x# = GetSpriteX ( 1 )
y# = GetSpriteY ( 1 )
rem work out movement direction
x1# = x# - mX#
y1# = y# - mY#
rem face the correct angle
angle# = ATanFull ( x1# - x#, y1# - y# )
SetSpriteAngle ( 1, angle# )
SetSpritePosition ( 1, GetSpriteX ( 1 ) + ( mX# / .50 ), GetSpriteY ( 1 ) + ( mY# / .50 ) )
rem scroll the screen
SetViewOffset ( x# , y# )
rem play animation
if ( GetSpritePlaying ( 1 ) = 0 )
PlaySprite ( 1, 35, 1, 1, 24 )
endif
endif
rem update the screen
sync ( )
loop