Multi dimensional arrays

BlitzMax Forums/BlitzMax Programming/Multi dimensional arrays

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.

Type TGameBoard

	Global x,y,z,width,height,trans
	Global layer
	Global data:Int[1,1] '  <-----THIS IS THE ARRAY I WOULD LIKE To SPECIFY THE SIZE OF FROM CALLING A Function

	Global cellWidth = 10
	Global cellHeight = 10
	
		
	Function Create:TGameBoard(Width,Height)
		Local tempGameBoard:TGameBoard = New TGameBoard
		layer:+1
			Local tempArray:Int[Width,Height]
		
			tempGameBoard.width = Width
			tempGameBoard.Height = Height
			tempGameBoard.data = tempArray

		Return tempGameBoard
	End Function
	
	Method drawBoard()
		'For Local repx=EachIn data
		For repx = 0 To (width-1)
			For repy = 0 To (height-1)
				xpixel = (repx*cellWidth)+(10*repx)
				ypixel = (repy*cellHeight)+(10*repy)
				data[repx,repy] = 1
				If data[repx,repy] = 1 Then DrawOval(x+xpixel, y+ypixel, cellWidth, cellHeight)
			Next
		Next
	End Method
	
End Type

Local t:TGameBoard = TGameBoard.Create(20,20)

Graphics 640,480,0,0

While Not KeyDown(KEY_ESCAPE)
Cls
t.drawBoard()
Flip
Wend
End


Or you can re-assign the array via a temp one when creating.