deleting items from 2d arrays
Michael P.
baseball.mjp at gmail.com
Thu Aug 13 19:59:37 PDT 2009
Okay, so I'm making a breakout type game in D. Using Derelict.
I have a 2d array of Block type variables(not important what's in them) declared like this:
Block[][] level;
and later load into like this:
level = loadLevel( "levels.txt", levelNumber );
Anyways, what I want to do is that when the ball hits one of the blocks in the array, I remove it. When a line no longer has any blocks in it, I remove that line/row. When there are no more lines, I load the next level.
Any ideas on how I could achieve this?
foreach( Block[] ba; level )
{
foreach( Block b; ba )
{
if( checkCollision( ball, b.p ) )
{
//remove the block??
}
}
}
The level array has 12 lines of 'x' amount of bricks. x can be as great as 10.
-Michael P.
More information about the Digitalmars-d-learn
mailing list