; Step 4 ; We were moving the background directly. ; Let's use variables Screen_PosX and Screen_PosY to move the screen. ; And relate background position to that. ; ; When background fits exactly on screen, the background position is: ; ; ( 0 , 0 ) ; ; So if we move the screen left.. ; ; Screen_PosX = Screen_PosX - 1 ; ; The background will move right! ; So the position of the background *on screen* ; is the reversed of the position of the screen. ; ; Back_ScreenPos = -Screen_Pos ; ; What we're doing here is exactly the same as in the previous step. ; Only we're using *real* relative positioning using new variables. ; ; So if we move the screen half a screen towards the upperleft.. ; ; +---------------+ ; | | - Screen ; | | ; | | ; | O - - - |-------+ ; | | | | - Background ; | | | ; | | | | ; +---------------+ | ; | | ; | | ; | | ; +---------------+ ; ; Then the screen position would be: ; ; ( -Screen_SizeX / 2 , -Screen_SizeY / 2 ) ; ; And the background would start on screen at: ; ; ( Screen_SizeX / 2 , Screen_SizeY / 2 ) ; ; E.g. the reversed. ; Let's use variables Back_ScreenPosX and Back_ScreenPosY ; to know where to draw the background on screen. Back_SizeX = GraphicsWidth () Back_SizeY = GraphicsHeight () ; Our view begins at ( 0 , 0 ) Screen_PosX = 0 Screen_PosY = 0 SetBuffer BackBuffer () Repeat ; Moving the screen directly If KeyDown ( 200 ) Then Screen_PosY = Screen_PosY - 2 If KeyDown ( 208 ) Then Screen_PosY = Screen_PosY + 2 If KeyDown ( 203 ) Then Screen_PosX = Screen_PosX - 2 If KeyDown ( 205 ) Then Screen_PosX = Screen_PosX + 2 ; Calculate the background position on screen ; using the screen position. Back_ScreenPosX = -Screen_PosX Back_ScreenPosY = -Screen_PosY Rect Back_ScreenPosX , Back_ScreenPosY , Back_SizeX , Back_SizeY , False Flip Cls Until KeyHit ( 1 ) End