GameMaker Project: Space Shooter

Project Name: PX_Lastname_SpaceShooter

Difficulty: Intermediate

Estimated Time: 2–4 class periods

Project Description

Create a 2D Space Shooter game in GameMaker. The player controls a spaceship that moves around the screen and fires bullets at enemy ships.

The player earns points for destroying enemies. If an enemy touches the player's ship, the player loses health. The game ends when the player's health reaches zero.

Your completed game must include:


Learning Objectives

By the end of this project, students will be able to:


Part 1 – Create the Project

Create a new GameMaker project.

Save the project as:

PX_Lastname_SpaceShooter

Replace X with your class period and Lastname with your last name.

Example:

P2_Smith_SpaceShooter


Part 2 – Create the Sprites

Create the following sprites:

Player

Name:

spr_player

Use a spaceship graphic or create your own.

Recommended size:

48 × 48 pixels


Bullet

Name:

spr_bullet

Create a small laser or projectile.

Recommended size:

8 × 16 pixels


Enemy

Name:

spr_enemy

Create an enemy spaceship.

Recommended size:

40 × 40 pixels


Part 3 – Create the Objects

Create these objects:

ObjectSprite
obj_playerspr_player
obj_bulletspr_bullet
obj_enemyspr_enemy
obj_controllerNo Sprite

The controller object will manage:


Part 4 – Player Variables

Open:

obj_player

Add a Create Event.

Enter:


move_speed = 5;

health = 100;

shoot_delay = 15;
shoot_timer = 0;

Explanation

move_speed

Controls how fast the player moves.

health

Stores the player's health.

shoot_delay

Controls how much time must pass between shots.

shoot_timer

Tracks when the player is allowed to fire another bullet.


Part 5 – Player Movement

Add a Step Event to obj_player.

Enter:


if (keyboard_check(vk_left))
{
    x -= move_speed;
}

if (keyboard_check(vk_right))
{
    x += move_speed;
}

if (keyboard_check(vk_up))
{
    y -= move_speed;
}

if (keyboard_check(vk_down))
{
    y += move_speed;
}

The player can now move using the arrow keys.


Part 6 – Keep the Player on the Screen

Add the following code underneath the movement code:


x = clamp(x, 0, room_width);
y = clamp(y, 0, room_height);

The clamp() function prevents the spaceship from leaving the room.


Part 7 – Shooting

Continue inside the player's Step Event.

Add:


if (shoot_timer > 0)
{
    shoot_timer--;
}

Then add:


if (keyboard_check(vk_space) && shoot_timer <= 0)
{
    instance_create_layer(x, y - 25, "Instances", obj_bullet);

    shoot_timer = shoot_delay;
}

Now the player can press the spacebar to fire.


Part 8 – Bullet Movement

Open:

obj_bullet

Add a Create Event.

Enter:


speed = 10;
direction = 90;

The bullet will move upward.


Part 9 – Destroy Bullets That Leave the Screen

Add a Step Event to obj_bullet.

Enter:


if (y < -32)
{
    instance_destroy();
}

This prevents old bullets from remaining in memory after leaving the screen.


Part 10 – Enemy Movement

Open:

obj_enemy

Add a Create Event.

Enter:


speed = 3;
direction = 270;

The enemy will move downward.


Part 11 – Destroy Enemies That Leave the Screen

Add a Step Event to obj_enemy.

Enter:


if (y > room_height + 32)
{
    instance_destroy();
}

Part 12 – Create the Score

Open:

obj_controller

Add a Create Event.

Enter:


score = 0;

GameMaker includes a built-in score variable.

The score starts at zero.


Part 13 – Spawn Enemies

Still inside the controller's Create Event, add:


alarm[0] = 60;

Now add an:

Alarm 0 Event

Enter:


var enemy_x;

enemy_x = irandom_range(40, room_width - 40);

instance_create_layer(
    enemy_x,
    -40,
    "Instances",
    obj_enemy
);

alarm[0] = irandom_range(30, 90);

Enemies will now appear at random locations across the top of the screen.


Part 14 – Bullet Hits Enemy

Open:

obj_bullet

Add a collision event with:

obj_enemy

Enter:


score += 10;

with (other)
{
    instance_destroy();
}

instance_destroy();

When a bullet hits an enemy:

  1. The player receives 10 points.
  2. The enemy is destroyed.
  3. The bullet is destroyed.

Part 15 – Enemy Hits Player

Open:

obj_enemy

Create a collision event with:

obj_player

Enter:


other.health -= 20;

instance_destroy();

Each enemy collision causes the player to lose:

20 health points


Part 16 – Player Death

Return to the Step Event for:

obj_player

Add:


if (health <= 0)
{
    room_goto(rm_gameover);
}

You will create the Game Over room later.


Part 17 – Display the Score and Health

Open:

obj_player

Add a:

Draw GUI Event

Enter:


draw_set_font(-1);

draw_text(20, 20, "Health: " + string(health));

draw_text(20, 50, "Score: " + string(score));

The player's health and score will now appear in the upper-left corner.

Example:


Health: 100
Score: 50

Part 18 – Create the Main Game Room

Create a room named:

rm_game

Recommended size:

1024 × 768

Place the following objects in the room:

Place the player near the bottom center of the screen.

Example:


           ENEMY

      ENEMY       ENEMY


             ↑
           Bullet


            SHIP


Health: 100
Score: 0

Part 19 – Create a Game Over Room

Create another room named:

rm_gameover

Create an object:

obj_gameover

Place it in the Game Over room.

Add a Draw Event.

Enter:


draw_set_halign(fa_center);

draw_text(
    room_width / 2,
    room_height / 2,
    "GAME OVER"
);

draw_text(
    room_width / 2,
    room_height / 2 + 50,
    "Final Score: " + string(score)
);

draw_text(
    room_width / 2,
    room_height / 2 + 100,
    "Press SPACE to Play Again"
);

Part 20 – Restart the Game

Add a Step Event to obj_gameover.

Enter:


if (keyboard_check_pressed(vk_space))
{
    score = 0;

    room_goto(rm_game);
}

Pressing the spacebar will restart the game.


Required Features

Your completed Space Shooter must include all of the following:


Required Controls

ControlAction
Left ArrowMove Left
Right ArrowMove Right
Up ArrowMove Up
Down ArrowMove Down
SpacebarShoot

Minimum Game Requirements

The player must begin with:

100 Health

Each enemy collision must remove:

20 Health

Each destroyed enemy must award:

10 Points

The player loses when:


Health <= 0

Testing Checklist

Before submitting your project, test each item.


Challenge Features

Students who finish early may add one or more of the following.

Level 1 – Easy

Add a space background.

Add sound effects for:


Level 2 – Moderate

Create different enemy speeds.

Example:


speed = irandom_range(2, 6);

Level 3 – Moderate

Add a health pickup.

Create:

obj_health

When the player touches it:


health += 20;

if (health > 100)
{
    health = 100;
}

instance_destroy();

Level 4 – Moderate

Add rapid-fire power-ups.

Temporarily reduce:


shoot_delay

Level 5 – Advanced

Create multiple enemy types.

Examples:


Level 6 – Advanced

Give enemies health.

Example:


enemy_health = 3;

The enemy must be hit three times before being destroyed.


Level 7 – Advanced

Create enemy bullets.

Enemies periodically fire bullets toward the player.


Level 8 – Advanced

Create a boss battle.

The boss should have:


Submission Requirements

Submit the following:

1. GameMaker Project

Project name:

PX_Lastname_SpaceShooter

2. Screenshot

Submit a screenshot showing:

3. Gameplay Video

Record at least:

10 seconds

The video must show:

4. Google Classroom

Upload all required files to the assignment in Google Classroom.


Grading Rubric

RequirementPoints
Player movement works10
Player stays inside room5
Shooting works10
Bullets move correctly5
Enemies spawn10
Enemies move correctly5
Bullet/enemy collision works10
Score system works10
Player health works10
Player/enemy collision works10
Health and score displayed5
Game Over system works5
Game can restart5
Total100

Concepts Used

This project demonstrates:

Final Goal

When finished, your game should function like a basic arcade Space Shooter:

Move → Shoot → Destroy Enemies → Earn Points → Avoid Enemies → Stay Alive