Breakout

An animated image of breakout gameplay

Continuing with the 20 Games Challenge, I've implemented breakout as a PICO-8 game. I found it was quite similar to pong, the previous game I wrote, though I ran into some new troubles. Notably, the ball is supposed to increase in speed as you break bricks. The way I'm handling the movement of the ball is by increasing or decreasing the x and y position by the x and y speeds, respectively. This broke my collision detection when the y position for the ball skipped over the y position for a block or paddle, in which case the ball would simply pass through the object instead of colliding with it. Initially I thought I could work around this by keeping track of the ball's previous and next y positions, then checking if the y position of the paddle or block were in between those two points, in which case a collision would have occurred, but I decided this would be too complex to maintain as the ball's speed could grow to be too large and lead to janky movement where it would detect a collision and reverse direction before it even appeared to touch the object it collided with. So, instead I opted for the simpler solution of just putting a max limit on the ball's speed that ensured it never moved two entire pixels in one frame, that way it would never skip over another object's y position. It's not ideal, and if this were an actual project I intended to ship I'd spend far more time on this to make it better, but this is just a learning exercise and not a game I'm particularly interested in spending a ton of time on. Feel free to play my implementation if you're so inclined to do so!

A PICO-8 cartridge for my implementation of breakout. Click to play!