Another brick in the wall

Like last week’s update, this one is going to be short as well. However, this time it’s because I don’t have a lot of spare time for making the post instead of not having a lot of time to actually do any work. Plus I feel like I should probably get as far away from the internet as possible before this post lands and this week’s horrible pun title comes back to bite me.

So the first thing to report is that the new Brick entity is now complete. To begin with it was just a dirt simple Entity subclass which took care of its own sprite sheet (and thus rendering) with an exposed color property to indicate how it should render. The BrickGrid entity was then changed to create an array of Brick entities instead of an array of numbers, with a few minor changes in a few places (e.g. brick becomes brick.color in places that need to know the brick type, and things of that nature).

With that in place I started in on the next phase, which was to include a life property that indicates how many times the ball needs to strike the brick in order to remove it from the grid. This gets set to 0 for bricks that are empty, 3 for red bricks and 1 for everything else. This required some other slight modifications in the Brick entity; previously it would return a boolean to tell you if a brick was at a location, but it needed to be switched to return an actual Brick entity at the location, so that the life can be checked. It’s then a simple matter to decrement the life and only remove the brick when the life hits 0.

This works but causes confusion for players when the ball hits a brick but the brick doesn’t get removed right away. Knowing that I planned on including invincible bricks, I went ahead and added the notion of “maximum” life as well as life, so that the brick can tell when it’s damaged partially. I also drew some fairly crude overlay images to show cracks in the bricks, so that while the brick is damaged, you can visually tell that the impact did something.

I also added another property called invincible which denies requests to alter the life value while it’s set. This is set on black bricks, making them impossible to remove. I tried to think up some ways to make such bricks more visually distinguished, but in the end I decided that since bricks either vanish or look cracked, it should be obvious that such bricks are just invincible. I even managed to remember that invincible bricks should not count towards the brick count in the level, since they can’t be destroyed.

The last change I made was to make the maximum life value of the brick be a score multiplier so that bricks with more life are worth more points when you destroy them. This is a simple linear thing for the moment since there aren’t a lot of levels to play test with just yet.

I also had an idea for bricks that would start out “locked” with a little padlock item on them which would be invincible until you destroyed all of the blocks with “keys” on them, to add a little more strategy to the level. However since i’m currently applying brick properties based on color and not level information I didn’t bother with that one and instead made a note to do it later on when more levels are created.

The next task upcoming will be to experiment with the ball only being able to remove a single brick between collisions with the paddle. As I recall this is just an experimentation thing, but it will give me the ability to make an extra kind of brick which will be destroyed without reflecting the ball, which seems like it might also be neat for some level designs or possible paddle power ups.