side-scrolling tutorials?

Blitz3D Forums/Blitz3D Beginners Area/side-scrolling tutorials?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Try something like the following (depending on how you set up your maps, of course).

Const TILESIZE = 32
Global tiles = LoadAnimImage("tiles.bmp", TILESIZE, TILESIZE, 0, 16)

Type platform
	Field x,y
	Field frame
End Type

; The offsets say how far left or down the map has been scrolled

Function DrawMap( Xoffset, Yoffset )

	; Cycle through each platform created
	For p.platform = Each platform
		x = p\x - Xoffset
		y = p\y - Yoffset

		; Check if tile is visible (on-screen)
		If (x > -TILESIZE) And (x < GraphicsWidth())
			If (y > -TILESIZE) And (y < GraphicsHeight())
				; If visible, draw it
				DrawBlock tiles, p\x - Xoffset, p
			EndIf
		EndIf
	Next

End Function
Adding to the offsets in this example will scroll the screen right and down (it is assumed that the offset of 0, 0 is the top-left corner of the map). Using Origin is not recommended as it affects all drawing commands including viewports. This means if you were to put a heads up display in the game, it would scroll with the map. It also means you're "drawing" stuff which isnt onscreen which can slow the game down.