Code an explosive homage to Bomb Jack | Wireframe #59

Help Jack collect the bombs in a remake of the arcade hit, programmed in Python and Pygame Zero. Mark Vanstone has the code, straight from this month’s Wireframe magazine.

In 1984, a new hero flew into arcades. Developed by Tehkan (later Tecmo), Bomb Jack saw its caped protagonist leap around platforms, collecting bombs while avoiding the patrolling enemies. Jack gained extra points for collecting bombs with burning fuses, and once the screen was cleared, it was onto the next globe-trotting location. Bomb Jack was soon ported to home computers, and received several sequels and re-releases, including one for the Nintendo Switch.

Each of Bomb Jack’s levels had different backgrounds and platform layouts to keep things fresh.

For our Python remake, we’ll focus on the unique way Jack moves around the screen. He can jump very high and float back down, while his cape can be used to guide him left and right and glide at a slower pace. Using Pygame Zero, we’ll start with the Egyptian background from the original game and then add some platforms over the top. We’ll use a different image for each platform and create an Actor for each one. We can put these Actors in a list, which will make it easier to check for collisions later. We also make an Actor for Jack and add a couple of extra properties so that we can track his direction and thrust. Once this is done, we can create Actors for our bombs. We define a list of coordinates to represent the position of each bomb, and then loop through that list creating a bomb Actor in each location and then adding the Actor to a list of bombs.

Our draw() function will first draw the background followed by the platforms (from the platform list we created earlier), then the bombs from the bomb list, and then Jack. We can also add the score at the top of the screen. You’ll see that the bomb Actors also have a property called ‘state’, which we’ll use later when checking to see if Jack has collected them or not. A gameState variable can also be set when all the bombs have been collected to trigger the display of a message saying that the level has been completed.
In our update() function, we’ll handle Jack’s movement. We can assume that Jack is facing forward to start with, and then we can adjust his direction depending on what keys are being pressed or if he’s jumping up or floating down. We need to do two collision checks because we don’t want Jack to jump up through the bottom of a platform, but at the same time, we want him to land on top of a platform if he’s falling down. If there are no collisions, then we increase Jack’s Y coordinate to simulate gravity, and to counter that, subtract any thrust value that should be applied. The thrust value is reduced each update until it gets to zero. If the left or right keys are pressed and Jack’s falling, we move his X coordinate accordingly and give him a little boost upwards to stop him falling so quickly. If he’s on a platform, we display animation frames to make him run left or right. We capture the jump key press in the on_key_down() function and make the thrust property equal to 20, which will send Jack up in the air.

Collect all the bombs in our homage to Bomb Jack.

The other part of the update() function checks the state of the bombs. We run through the list of bombs, checking to see if Jack has collided with them. If he has, we set the bomb state to a value higher than 1. This sets off an animation cycle through a few frames until the bomb disappears. In this loop, we count how many bombs have reached the invisible state – when that number reaches the total number of bombs, we set gameState to 1 and the level is completed.

To expand the project, you could put in some baddies, and don’t forget that lit bomb fuses can give Jack a bonus if he collects them while they’re fizzing. As ever, we’ll leave those for you to add.

Here’s Mark’s code for a Bomb Jack-style platformer. To get it working on your system, you’ll first need to install Pygame Zero. Full instructions can be found at For the full code listing, head to our Github.

Get your copy of Wireframe 59

You can read more features like this one in Wireframe issue 58, available directly from Raspberry Pi Press – we deliver worldwide, and there are plenty of subscription offers to save you money on the price of an issue.

And if you prefer your magazines in digital form, you can also download Wireframe issue 58 as a free PDF!

No comments

Comments are closed