; Step 3 ; Imagine a huge world, 300 screens wide, 300 screens high. ; When the screen is in the middle of this world, you'd have this: ; ; +----------------------------------------------------------------+ ; | | ; | (world) | ; | | ; | | ; | | ; | | ; | | ; | | ; | | ; | (screen) | ; | | ; | O---+ | ; | | | | ; | | | | ; | +---+ | ; | | ; | | ; | | ; | | ; | | ; | | ; | | ; | | ; | | ; | | ; | | ; | | ; | | ; +----------------------------------------------------------------+ ; ; The point marked 'O', being the upperleft corner of the screen ; is indeed coordinate (0,0) with screen orientation. ; But in world orientation, it is definitely not :) ; ; This is the same with our background scenario. ; Suppose our background has the same size as the screen as before. ; Now let's move the background a bit and see how our orientation changes. ; ; +-------------+ ; | | - Background ; | | ; | | ; | O-------------+ ; | | | | - Screen ; | | | ; | | | | ; +------|- - - + | ; | | ; | | ; | | ; +-------------+ ; ; Point marked 'O' is in the middle of the background. ; So upperleft of background is half the size of background further. ; If we were to draw the background on the screen, ; we'd have to find out exactly where this is. ; ; Let's recap. ; In our original scenario the background was on position (0,0) ; being placed exactly within screen boundaries. ; In the picture above the background is actually moved half the ; size of the background towards the upperleft corner. ; ; Suppose we use variables Back_SizeX and Back_SizeY as the ; background size. ; If the background is moved left and up half the size of the ; background, the coordinate would be: ; ; ( -Back_SizeX / 2 , -Back_SizeY / 2 ) ; ; Suppose we can move the screen, like a camera, over the background. ; So if we move the screen right, the background will move left. ; Let's use variables Back_PosX and Back_PosY to know ; where to draw the background *on screen*. Back_PosX = 0 Back_PosY = 0 Back_SizeX = GraphicsWidth () Back_SizeY = GraphicsHeight () SetBuffer BackBuffer () Repeat ; The movement of background is reversed of the screen movement. If KeyDown ( 200 ) Then Back_PosY = Back_PosY + 2 If KeyDown ( 208 ) Then Back_PosY = Back_PosY - 2 If KeyDown ( 203 ) Then Back_PosX = Back_PosX + 2 If KeyDown ( 205 ) Then Back_PosX = Back_PosX - 2 Rect Back_PosX , Back_PosY , Back_SizeX , Back_SizeY , False Flip Cls Until KeyHit ( 1 ) End