The trap is sprung!


Time to move on to the next phase of the game! When the player has had a chance to dig their hole, Dolan’s Caddy eventually arrives and falls in. I had originally hoped to implement some sort of Jellycar-style soft-body physics, with the car twisting and flipping and bouncing off the remaining blocks. But then I remembered that the real name of the game is Aggressive Scope Reduction. So instead, the car stays horizontal and just bounces back and forth; it isn’t remotely physically accurate, but it’s fun enough and only took a day to get working, and I’ll take it!

Donald sprung into action and produced some debris particles and damaged variants of the car bumper to swap in after the initial collision. We also decided that the car should be one row of sprites taller (less Seville, more Escalade) as a way to challenge the player to dig a deeper hole.

The collision detection takes advantage of the fact that the grid of blocks and the road around them is basically a 1D heightmap. Given the board state at the end of the match-3 phase, I compute a 16x16 grid of which tiles in the whole screen should be treated as empty/passable or occupied/impassable (stored as a series of bitmasks). I also manually placed a series of query points along the bottom, front, and back of the Cadillac sprite. Each frame, I tentatively advance the car’s position, and then iterate over the query points and figure out which “bit” each one is now in. If any of them are in an occupied cell, I roll back the car’s movement to the edge of the impassable cell, and either reverse the X velocity or zero out the Y velocity as appropriate.

I was originally debugging this implementation using PRINTH() statements, but that was going nowhere fast. Then I realized that I could just draw the collision “geometry” in about 4-5 lines of debug code, and that made everything much easier!

Get Dolan's Cadillac

Leave a comment

Log in with itch.io to leave a comment.