Updating Block Breaker – Power Ups

Block Breaker Gameplay Image Lazer Firing

Sharing is caring!

Block Breaker is a game I’m currently developing. It’s a simple game where you have to use a paddle to bounce a ball into bricks to destroy them. The game was working and had only 1 feature which was to hit a brick with a ball and collect the brick with the paddle. I wanted to add some more features to the game so I implemented a power up system where a brick would have a chance to release a power up when it is first hit.


The first thing to do was define the power up types for Block Breaker. I went with these:

  1. Magnetism (allows user to pull/push bricks)
  2. Magnet power (increase the force applied by the magnetism)
  3. Laser beams ( one from each side of the paddle)
  4. Bombs (a bomb released from paddle)
  5. Extra Ball ( an extra ball )
  6. Magnetic ball ( can be attracted/rejected by magnetism)
  7. Ball Laser guides ( Current balls get a directional laser showing direction )
  8. Extra Score ( increase score )

Once all the power ups were defined I created a Power Up class which contained all types of power ups types and powerup data such as the box2d body.

With the power ups defined I wanted them to have a chance at getting created when the bricks were hit so I added a method call to the game model where the bricks change from static( bricks not hit yet ) bricks to dynamic (bricks that have been hit).


The code below gives the Power Ups a 20% Chance of being created.

The code above calls this method below to create a new body for the Power up and then randomly sets which type of power up it is and assigns the matching texture.

Now Power Ups are given a chance to spawn and appear on the screen. The next thing I needed to do was allow the paddle to pick up the Power ups. In order to do this I added some conditions in the contact listener which then told the model to gave the player the power up. The code below is from the contact listener.

Now everything is in place for me to add the individual power ups. For each of the power ups I added a flag to signify which power up was needed. Then each update tick I would check the flags and add the power ups and reset the flags.


Block Breaker is now able to dish out power ups to players. The next step would be to implement the individual power up abilities however that’s for another time. If you want to try Block Breaker you can download it from here.

Sharing is caring!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.