Morgan's Projects: Breaker

Breaker is a Breakout clone written using C++ and the SDL (Simple DirectMedia Layer) graphics library. All the artwork is of my own creation and was produced using The GIMP image editor.

The game is only a very small (5 level) demo but can be expanded to include as many levels as the user wants simply by using a text editor to edit the level definitions file. The reason I'm using a text file to define levels is two-fold:

I think you'll agree that using a text editor not pretty, but it's practical! As the development of Breaker progresses, I'm hoping to create a level editor and make the demo into a proper game with menus, etc.

Developer Blog

23rd January 2009

I've started the development of Breaker using the basic SDL template defined in Code::Blocks which provides a good starting point in creating a window - which is what I want. So far I've created three sprites: A bat, a ball and a single brick.

As you can see from the screen shots, I've only just got the basic mechanics of the game in place:The ball is actually just free-moving (it doesn't yet register hitting the bat) and simply bounces off the edges of the screen. The bat can be moved left and right by the player and won't move past the edges of the screen.

25th January 2009

I should warn you that these updates won't be too frequent and won't always have lots of info simply because I'm looking for a job and I'm trying to put the projects portfolio together for this website aswell as complete three other programming projects.

I finalised the brick graphics. There are 9 in total: 7 of differing colour and two special bricks - one which I have designed to take multiple hits and the other is indestructible.

The ball now registers hits on the bat and will move away at a angle relative to the horizontal position it hits the bat, however the ball still bounces off all four edges of the screen.

Finally, I made use of SDL_Delay so that the game multi-tasks nicely. The downside is that my laptop no longer keeps the room warm whilst I'm testing :(

28th January 2009

As you can see from the screen shot I've got a brick drawn on screen. It's there because I'm testing the new image loading function I've written which removes the process from the body of the main() routine. The brick shown is the indestructible design.

The ball's behaviour is now set so that it stays rested on the bat until the player launches it by pressing the spacebar. The ball will also travel off the bottom of the screen whereupon it returns to the resting position on the bat.

Just as exciting is the fact that I've also designed the first level layout so I hope to have that showing on the next update!

Update! I've actually pushed hard and designed all five levels and got them to layout on screen. Check out the last screenshot (it's level 4!)

29th January 2009

Having put a lot of effort into Breaker yesterday, I've made considerable progress. In fact, outside of not having background graphics and some game niceties like menus, it's nearly a complete game.

Collision detection is (with the exception of fine tuning) complete and includes the logic for multi-hit and indestructible blocks. I've improved the bat collision detection a little so that the game isn't prone to 'spinning' the ball inside the bat. The score, level name and lives are all updated accordingly and displayed using the SDL_ttf library. I've also sped up the bat a little and to start with the ball travels slowly but increases speed as the player progresses through the levels.

Possibly the biggest announcement for today is that I'm releasing Breacker into the wild. Yes, that right! You can download the game using the links at the bottom of the page. Please keep in mind that the game is still very basic!

30th January 2009

There's been a few minor changes I've made to the code:

Closing Comments

Weighing in at just over 450 lines of code and taking under seven days to develop, you can imagine Breaker won't set the world on fire, but it's small (the contents of the whole directory is less than 1Mb) and fast. Whilst I'm going to leave this project alone for now I'd like to come back to it and tidy some of the code up, add some more levels and do some menus, level intros and a high score table - maybe even an online high score table :) All in all though I'm pretty happy with the way the game turned out considering it's my first game written using the SDL libraries.

Don't forget to download the game and have a play with it (and try to beat it. I know I can't - the furthest I've got is level 3 :D) You can also download the source files for it (including the GIMP .xcf image files.)

Finally, you might be wondering why the window border colour changes so often during the updates in this project. That's because I've been messing about with themes in Ubuntu, trying to find one I like. I went from Glossy to Dust, then Ubuntu crashed and reset the theme to the blue one, then I reset back to Dust. Hopefully, my theme will now remain the same (it's back to glossy green again!)

Downloads

Click here to download Breaker installer for Windows (32-bit) Click here to download Breaker for Linux (AMD 64-bit only), Debian installer.

The source archive and Linux distributions will be available soon!

Whilst the Windows installer will add an entry to the Start menu, you will need to set up a menu for your Linux desktop environment. The shortcut needs to execute: /usr/bin/Breaker.

If you can have questions or want to report a bug with this project, please contact me using this email link