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
;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