TileMap Array and only drawing whats on screen?

BlitzMax Forums/BlitzMax Beginners Area/TileMap Array and only drawing whats on screen?

Can someone post a code example using this bit of code here?

SuperStrict

Graphics 800, 600

Global grass:TImage = LoadImage("grass.png") 

Const MAPWIDTH:Int = 8000 / 32
Const MAPHEIGHT:Int = 8000 / 32

Global MapStartX:Int = 0
Global MapStartY:Int = 0

Global MapArray:Int[MAPWIDTH, MAPHEIGHT] 

For Local x:Int = 0 Until MAPWIDTH
	For Local y:Int = 0 Until MAPHEIGHT			
		MapArray[x, y] = Rand(0, 3) 
	Next
Next

While Not KeyHit(KEY_ESCAPE) 
	
	Cls
		DrawGrass() 
	
	Flip
	
Wend

Function DrawGrass() 
	For Local x:Int = 0 Until MAPWIDTH
		For Local y:Int = 0 Until MAPHEIGHT
			If MapArray[x, y] = 1
				DrawImage grass, MapStartX + x * 32, MapStartY + y * 32, 0
			EndIf
		Next
	Next
End Function


It would be better for me to see the actual code. I learn better that way. :)

Thanks. :)