2D Array Help

Blitz3D Forums/Blitz3D Programming/2D Array Help

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.

I'm making a game like BREAKOUT but I don't know the best way to set up a 2D array of blocks. I thought of something like this but I don't know if it is that efficient and worth going through the trouble to make.

;Here some of my code

;a type to handle the blocks

Type BlockType

Field x,y ;coordinates

End Type

;creates a block row 'DUH'

Function CreateBlockRow(x,y)

maxBlocks = 8
x_spacing = 100

For i = 0 To maxBlocks

block.BlockType = New BlockType
block\x = x
block\y = y

[draw the block image here]

x = x + x_spacing;the blocks won't be very wide

Next

End Function

Function SetupBlocks()

block_rows = 3

y_gap = 0 ;once again,blocks are not very big

For ii = 0 to block_rows

CreateBlockRow(10,y_gap)

y_gap = y_gap + 150

Next

End Function