How to side scroll?

BlitzMax Forums/BlitzMax Beginners Area/How to side scroll?

if you want a dead easy way to have the camera follow your player do this:

SetOrigin(-(player.x-GraphicsWidth()/2),-(player.y-GraphicsHeight()/2))

Graphics(640,480)
Global player:Tplayer=New Tplayer

Type Tplayer
Field x:Float,y:Float,speed:Float=10
Method do()
	If KeyDown(KEY_UP) y:-speed
	If KeyDown(KEY_DOWN) y:+speed
	If KeyDown(KEY_LEFT) x:-speed
	If KeyDown(KEY_RIGHT) x:+speed
	DrawOval(x,y,20,20)
EndMethod
EndType

Function grid()
	For Local i:Int=0 To 10
		DrawLine(0,i*50,500,i*50)
	Next
	For Local i:Int=0 To 10
		DrawLine(i*50,0,i*50,500)
	Next
EndFunction


While Not AppTerminate()
	Cls
	SetOrigin(-(player.x-GraphicsWidth()/2),-(player.y-GraphicsHeight()/2))
	grid()
	player.do()
	Flip
Wend