Rectangles of a value in a 2d array.

BlitzMax Forums/BlitzMax Beginners Area/Rectangles of a value in a 2d array.

how is this?

Local dx:Int = 640
Local dy:Int = 480
Local dungeonplan:Int[dx,dy]


Function fillroom(layout:Int[,], x:Int, y:Int, w:Int, h:Int)
	For Local i:Int = 0 Until w
		For Local j:Int = 0 Until h
			layout[x+i, y+j] = True
		Next
	Next	
End Function

fillroom(dungeonplan, 0, 0, 50, 50)       'make some "rooms" in array
fillroom(dungeonplan, 100, 0, 50, 50)
fillroom(dungeonplan, 0, 100, 40, 60)
fillroom(dungeonplan, 300, 400, 90, 20)

Graphics(dx, dy)                'display the contents of the array
SetColor(255, 255, 255)

For Local x:Int = 0 Until dx
	For Local y:Int = 0 Until dy
		If dungeonplan[x, y] = True Plot(x, y)
	Next
Next

Flip

WaitMouse()


ugly... no error checking to make sure values are not written beyond array boundaries... but there you go.