Space Invaders, Phoenix, Phantom Star—you've seen shoot-em-ups before. They can come in a variety of styles, but in general they're games where you play as a single ship with unlimited firepower firing recklessly and indiscriminately on groups of "enemies" that are only trying to defend their home planet. Cruelty is fun.
This tutorial will guide you step by step in making a simple shoot-em-up. First, as with any game, we need to decide what our game should look like. Let's just stick with one level for the purposes of this tutorial, but we can have a lot of fun with how enemies and bullets move. Let's get creative; maybe something like this?
Like with all my programs, the code's split into sections, because it makes debugging that much easier. We start my making the main program ASHMUP
that sets everything up:
prgmASHMUPD
will hold our data, prgmASHMUPI
will set up (initiate) the variables, and prgmASHMUPR
will hold all our subroutines. The actual game goes in the loop, so the user can quit at any time by pressing CLEAR. prgmASHMUPK
handles user keypresses (and moves the ship accordingly), while prgmASHMUPM
moves and tests the enemies and bullets.