Creating a fixed shooter game

Yea! Shooter games are fun!

Today we're going to make a basic shooter game! More specifically, ours will be a fixed shooter. Some popular fixed shooters include Space Invaders, Galaxian, and Galaga.

The object of our game is for the player to destroy all enemy ships.

Rules/Structure:

  • The player can move his ship left or right, but it stays at the bottom of the screen.
  • Enemies move from the top of the screen to the bottom.
  • If the player's ship hits an enemy ship, the player will lose a life.
  • If an enemy's ship passes the bottom of the screen, the player will lose a life.
  • The player can fire missiles by pressing spacebar. If a missile hits an enemy, the enemy (and the missile) is destroyed.
  • The game is over when the player runs out of lives or all enemy ships are destroyed.

This tutorial is divided into steps, and each step has a list of instructions. When you complete an instruction, you can click on it to mark it as complete. This will help you keep your place.

You can use the arrows at the left and right to navigate through this tutorial. The first step starts on the next page!

Step 0 - Getting started

Before we get started, we need to fetch the project using the file sync tool
  1. Close every application you have open except this one.
  2. Find the UBGD_FileSync_v2.2.exe file on the desktop and double click it. If it's not there, you can download it here.
  3. We want to download the project, so type "1" and then [ENTER].
  4. Select "Student Files" by typing "1" and then [ENTER].
  5. Find your name in the list. Type the number which corresponds to your name and then [ENTER].
  6. Find the project called "MyBasicShooterGame.gmx.zip". Type the corresponding number and then [ENTER].
  7. The Sync Tool will download your project, extract it, and launch it for you.
  8. When it's done, GameMaker Studio will be open.

Step 1 - Creating sprites

A "sprite" is the visual representation of a game object. Before we can create objects, we need sprites for them!

  1. Click on, drag, and drop the images below onto GameMaker Studio. Name each sprite as indicated.
    (Sprites were created for Galaga, by Namco and Midway)
      Name Description
    ship_sprite This is the ship the player will control
    miniShip_sprite This image represents the number of lives the player has.
    playerMissile_sprite This is the weapon the player can fire.
    enemy1_sprite This is the one type of enemy.
    enemy2_sprite This is the one type of enemy.
  2. Each sprite should be centered.
  3. Also, create an object for each of these sprites. Name them appropriately and mark them as solid.

Step 2 - Creating a level

Levels can be implemented in GameMaker Studio by creating a "Room". We'll make one now!

  1. Right-click on the "Rooms" folder, and select "Create Room".
  2. Add a single player ship near the bottom of the screen.
  3. Add several enemy ships in the top-half of the room.
  4. Be sure to save your work so far by clicking the button!

Step 3 - Making stuff happen

Alright, we've created our first level... but it doesn't do anything yet! Let's give our player control. We'll do this by adding keyboard events to the player's ship object.

  1. Double click the Player's Ship object under the Objects folder.
  2. Click the "Add Event" button at the bottom of this window and select the Keyboard <LEFT> key.
  3. Have the player's ship move -4 in the x-direction, relative to his current position.
  4. Now add an event for the Keyboard <RIGHT> key. Here, you'll use a positive 4 in th x-direction.
  5. Be sure to save your work so far by clicking the button!
  6. Once you're done, let's try out your game by pressing the button at the top left of GameMaker Studio.

Step 4 - Pew, pew, pew!

To clear each world, the player must destroy all enemy ships. He can do this by firing a missile at them.

  1. Double click the Player's Ship object under the Objects folder.
  2. Select the Keyboard <SPACE> event.
  3. Find and add the "Create Instance" action from the "Main1" tab. It looks like a single light bulb.
  4. In the Create Instance dialog, select the player's missile object.
  5. X and Y should be 0, with relative checked (we want to create the missile in the same spot the player's ship is in).
  6. Now we've created the missile, but it won't go anywhere just yet. First, we need to open the missile object.
  7. Now add the "Create" event for the missile object.
  8. Find and add the "Set Vertical Speed" action, with a speed of -8.

Step 5 - Shooting is fun... but even better when stuff blows up!

As of right now, we have 2 different enemy objects. We could add collision events for each one, but this will become cumbersome if we decied to add more enemy ships in the future. Instead, we'll create a "parent object" for the enemy ships and attach events to that.

  1. Right-click ont he "Objects" folder and select "Create Object".
  2. Name this object "enemyShip_parent" and mark it as solid.
  3. Click "OK" to close the "enemyShip_parent" for now, we'll come back to it in a moment.
  4. Open the "enemyShip1" object.
  5. On the left hand side of the Object window, you'll find a field labeled "Parent". Change the value of this field to the "enemyShip_parent" we just created.
  6. Repeat the previous step for the "enemyShip2" object. If you create your own ships later, you'll want to make those children of the enemyShip_parent as well.
  7. Now open the EnemyShip_parent object again.
  8. Add an event for "Collision" with a "playerMissile".
  9. When the missile collides with an enemy ship, things should happen:
    • Remove the enemy ship (Self)
    • Remove the missile (Other)
  10. Be sure to save your work so far by clicking the button!
  11. Once you're done, let's try out your game by pressing the button at the top left of GameMaker Studio. You should be able to steer the ship and fire missiles which move up the screen.

Step 8 - Beating the level

Right now, ships are being destroyed, but nothing happens when you destroy all of them!

  1. Open the "enemyShip_parent" object.
  2. Add a new event for "Destroy". (Recall that ships are destroyed when a missile collides with them, so we don't have to!).
  3. Add a "Test Instance Count" action.
  4. Set the object to the "enemeyShip_parent" object.
  5. Set the number to "1" and press OK.
  6. Next, add the "Restart Room" action.
  7. Save your game and play it! If you want to create a second level now, you can. Remember though, that it's often easier to duplicate an existing room and adjust it, rather than starting from scratch.

Step 9 - Losing the game

It's not fun if you can't actually lose, right? We'll give the player lives, and then remove one life everytime he runs into an enemy, or if an enemy goess off screen.

  1. First, let's give the player 5 lives. Open the playerShip object.
  2. Add a new event for "Game Start" (it's under the button labeled "other".
  3. Find and add the "Set Lives" action, in the "Score" tab.
  4. Enter a value of 3 (or whatever you want) and press ok.

Now that the player has lives, we can start taking them away!

  1. Open the "enemyShip_parent" object.
  2. Add a "Collsion" event for colliding with the playerShip.
  3. Add an action to destroy the enemyShip object (self).
  4. Add an action to destroy the playerShip object (other).
  5. Now open the playerShip object.
  6. Add the "Destroy" event to the playerShip object. By putting actions in here, we can have them processed regardless of how the ship was actually destroyed!
  7. For now, we just want to remove 1 life from the player when the ship is destroyed. Add the "Set Lives" action from the "Score" tab.
  8. Set the value to -1 relative.
  9. Can you figure out how to subtract one life when an enemy ship goes off screen?

Step 10 - Giving the player feedback

It's important to let the player know when they're doing well, and when they're doing poorly. We'll accomplish this by showing the player's score and number of available lives.

  1. Open the "playerShip" object
  2. Add a new event for "Draw GUI"
  3. Add the "Draw Score" action from the "Score" tab. I suggest drawing the score at the top-left corner (0, 0), but this is up to you.
  4. Add the "Draw the lives as image" action. Use the miniship_sprite. I suggest drawing the lives at the bottom-left corner (0, 480), but this is up to you.
  5. You'll need to determine when to award the player points and how many points to give them!

Step 11 - Making the enemies move

To make the game more exciting, we'll make the enemies move towards the player. We'll accomplish this using an alarm clock.

  1. Open the "enemyShip_parent" object.
  2. Add an event for "Create".
  3. From the "Main2" tab, add the "Set Alarm" action (it looks like a clock).
  4. Set "Alarm 0" to go off in 120 steps (FYI, by default, our games have 60 steps per second, so this is about 2 seconds).
  5. Now add an event for the Alarm activating.
  6. When this alarm is activated, we want 2 things to happen:
    • Make the object jump 8 pixels in the (relative) Y direction ("Jump to Position" action)
    • Reset Alarm 0 to 60 steps
  7. Be sure to save your work so far by clicking the button!
  8. When you play your game now, you should see the enemy ships begin to move after a short delay.

What's missing?

  • * Create a title/game over screen
  • * Take the player to the title/game over screen when out of lives
  • * Create levels with multiple waves of enemies
  • Reset the remaining enemy ships when the player's ship is destroyed. This will give the player a chance to recover.
  • Create enemies which can fire back.
  • * Create enemies which move in a unique way (left and right instead of straight down; diagonally; smoothly; etc).
  • Sound and visual effects (such as explosions)
  • Create a scrolling background.

* indicates mandatory items