DEV Community

Cover image for Blockbreaker
James Wallis
James Wallis

Posted on • Updated on • Originally published at wallis.dev

Blockbreaker

During my first year at the University of Portsmouth (2015), I had the opportunity to take part in a Python programming competition. To compete, we had to extend one of two base programs into a game. At the time I had only been programming for half a semester, so it appeared to be the perfect opportunity to develop software outside of university coursework. My entry was titled "Blockbreaker", a re-implementation of the classic game Brickbreaker. The competition was a success and I won first place 🥇.

Blockbreaker game screen


Game screen

Original brief

This is an individual competition – group entries are not allowed. Use only Python and the graphics module. Don't write (object-oriented) classes and do not use non-standard libraries such as PyGame – any modules you use apart from John Zelle's graphics.py must be part of the standard Python 3 distribution. However, if you want to add sound, I suggest using the winsound module (this only works on Windows, but you can assume that we will use a Windows computer to run your program). Do not re-write the game completely – it should still involve bat(s)/ball or an android eating apples (but of course, it could do other things as well!). Keep to the spirit of the unit and the competition, and make sure that your game would not offend anyone.

Blockbreaker game over screen


Game over screen

Technical Details

Blockbreaker is written in Python (2.7 but works with 3) and is made up of 3 types of components - the bat, walls and the blocks themselves. It predominately uses Lists to keep track of game items such as blocks and score, as every block has a different value. The game is constantly calculating whether the ball has hit any component and determines whether it needs to alter the trajectory of the ball. Matching the original Brickbreaker, when a certain amount of blocks are hit, the game levels-up, increasing the ball speed and altering the colour of the blocks. For creating the Graphics, it uses John Zelle's graphics.py which was used heavily in University coursework, and a requirement for the competition. It also uses built-in Python modules to read/write the high scores file, control the speed of the ball and randomise the direction of the ball when it hits a surface. The source code is available on Github.

Blockbreaker animation on startup


Block animation on startup

The source code for Blockbreaker is available on GitHub.

Top comments (0)