The idea for this game came from an old Vic 20 game called Blitz. The purpose of that and this game is to bomb the buildings to the ground so that a plane can land. The heights and distribution of the buildings are random for each level. The original game got harder after each level - this one remains reasonably challenging throughout.
The photograph above is of the screen of a Meowbit with this game loaded.
The plane is a 16x8 graphic. The bomb variable is used to make sure that the player cannot drop another bomb until the first one has exploded.
The buildings shown below are 16x16 sprites. The first and last column of pixels are left blank to leave a gap between the buildings. The flag is the finish line and is an 8x8 sprite.
This is quite a long function. The variables and repetition structures are used to draw the parts of each building to a random height. This function is the key to changing the way that this game looks.
The game should look like the screenshot. If not, check that you have the MakeBuildings function copied correctly.
When the plane reaches the right hand side of the screen, it is meant to wrap around and appear a little lower on the left hand side.
An 8x8 bomb is sufficient. It also leaves the possibility of hitting two buildings with one bomb.
Bombs Kill Buildings
Be careful with this function. Sprite and othersprite are not normal variables. Drag them from the event definition over the places you need to put them. Each time a bomb hits the building, it blows up a section of it.
Buildings Kill The Player
It's game over if the player crashes into one of the buildings.
Bombs Die On The Ground
Missing all of the buildings is costly for the player. It takes ages before they get another bomb to drop. Again, the sprite variable is dragged from the event definition into place, not made like a normal variable.
Reaching The End
The following code makes a little celebratory pause and restarts a new random level if the player reaches the end.
Challenges & Extensions
- When the player manages to land the plane, make an animation of a pilot appear next to the plane until the user presses a button to continue with the game.
- Have the game get ever so slightly more difficult each time the end is reached. One way to do that is to speed up the plane a little each time the level restarts. Another way is to start the plane a little lower each time.
- Think more carefully about the random numbers for the buildings. Each bomb takes out the same amount of building space. You could ensure that the same total number of building segments is used each time or increase it depending on the level.
- Add anti-aircraft fire to the game. Think about how that might work. Perhaps you have some guns on top of a few of the buildings. Maybe the plane can bomb the guns so that it can stay safe, maybe there is always a danger of being shot.
- You can edit the code that designs the buildings to add some variety to each level. You can design a sprite for the tops of the buildings and should be able to locate the place where you would add the top of the building. You can also use an array of images for the building sprites and choose one randomly when drawing the buildings.