I’m not a game developer, but, as most programmers do, I’ve always had some interest in the field. The first game that I wrote back in gymnasium was a two-player version of Snake. Written from scratch in Turbo Pascal 7, it featured such innovative design decisions as a completely text- and number-less HUD (I couldn’t figure out how to properly output text in graphics mode) and diagonally moving snakes (it made the keyboard controls easier to implement). Later, while studying AI in the university, I fiddled with neural networks and genetic algorithms and eventually used both to control the enemy ships in my version of Space Invaders.
Nothing much came of it. Once out of school, money became a primary concern, and I was already smart/cynical enough to know that game development took a lot of resources and that most beginner-made games failed to turn a profit. Sensibly, I didn’t even consider the option.
Then one day, as I was idly browsing through “hot” questions on StackOverflow, it occurred to me that I had never given this gamedev thing a proper shot. With a grand total of two completed games – written years apart – I could hardly even call myself a beginner. Obviously, that wouldn’t do. Recalling that most beginner-oriented articles recommend starting with something simple, I decided to go forth and implement a clone of the classic Breakout game. Which brings me to the crux of this post, i.e. presenting the game itself.
First, a couple of screenshots :
I’m sure you’re already familiar with the game mechanics of Breakout, so instead of the traditional feature list, I’ll instead highlight a few potentially interesting implementation details:
- Continuous collision detection – no matter how fast the ball is moving, it can’t “jump” through walls and blocks. Basically, instead of checking if the ball currently overlaps with another game object, I calculate the path it has taken in the previous frame and then see if that collides with anything.
- Multiple maps – each map comprises a pair of .png files. The first file is specifies the map layout, with each coloured pixel corresponding to one brick in the game. The other file is for brick metadata. Specifically, the red channel of this metadata image encodes the number of points the player gets for destroying the brick. This makes it easy to add and prototype maps – all you need is a basic image editor.
- Game state stack – states like “in-game”, “paused”, “game over” are handled using a simple stack-based “engine”. It makes for a cleaner, less ad-hoc design. See this tutorial for details.
- Written in Processing – a Java-based language specifically designed for interactive visualisation and easy prototyping. The code is largely self-contained, with only one external dependency – the Minim audio library.
Related posts :