; Step 7
; Let's control both the player and the 'screen view point'.
; So all we're doing is adding a section that changes the player
; position on background.
; And that's all there is to it! :)
Back_SizeX = GraphicsWidth ()
Back_SizeY = GraphicsHeight ()
Player_SizeX = 20
Player_SizeY = 20
; Orientation point.
Back_PosX = 0
Back_PosY = 0
; Player *starts* in middle of background.
Player_BackPosX = Back_SizeX / 2
Player_BackPosY = Back_SizeY / 2
View_WorldPosX = 0
View_WorldPosY = 0
SetBuffer BackBuffer ()
Repeat
; Up/down/left/right to control player (regular arrow keys).
; This is the only added part.
If KeyDown ( 200 ) Then Player_BackPosY = Player_BackPosY - 1
If KeyDown ( 208 ) Then Player_BackPosY = Player_BackPosY + 1
If KeyDown ( 203 ) Then Player_BackPosX = Player_BackPosX - 1
If KeyDown ( 205 ) Then Player_BackPosX = Player_BackPosX + 1
; Up/down/left/right on keypad to control view (arrow keys on keypad).
If KeyDown ( 72 ) Then View_WorldPosY = View_WorldPosY - 2
If KeyDown ( 80 ) Then View_WorldPosY = View_WorldPosY + 2
If KeyDown ( 75 ) Then View_WorldPosX = View_WorldPosX - 2
If KeyDown ( 77 ) Then View_WorldPosX = View_WorldPosX + 2
Back_ScreenPosX = Back_PosX - View_WorldPosX
Back_ScreenPosY = Back_PosY - View_WorldPosY
Player_ScreenPosX = Back_ScreenPosX + Player_BackPosX
Player_ScreenPosY = Back_ScreenPosY + Player_BackPosY
Rect Back_ScreenPosX , Back_ScreenPosY , Back_SizeX , Back_SizeY , False
Rect Player_ScreenPosX , Player_ScreenPosY , Player_SizeX , Player_SizeY , False
Flip
Cls
Until KeyHit ( 1 )
End