Hi people. I need to know how to define an array within a type, using a function (within the type) which takes the arrays dimensions which are passed to it.
Type gameBoard
Global x,y,z,width,height,trans;
Global layer;
Global data[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 createBoard:gameBoard(getWidth,getHeight)
layer:+1;
width = getWidth;
height = getHeight;
data=data[getWidth,getHeight]
'use slice to resize array
Return New gameBoard;
End Function
Method drawBoard()
'For Local repx=EachIn data
For repx = 0 To (width-1)
For repy = 0 To (height-1)
xpixel = repx*cellWidth;
ypixel = repy*cellHeight;
data[repx,repy] = 1;
If data[repx,repy] = 1 Then DrawOval(x+xpixel, y+ypixel, cellWidth, cellHeight);
Next
Next
End Method
End Type
I would like to know how to accomplish this without using lists :)
Thankyou for any help
|