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:
- Player spaceship
- Player movement
- Shooting bullets
- Enemy ships
- Enemy movement
- Bullet/enemy collision
- Player health
- Score system
- Game Over condition
Learning Objectives
By the end of this project, students will be able to:
- Create objects and sprites in GameMaker.
- Use keyboard input to control an object.
- Create objects dynamically during gameplay.
- Use variables to track health and score.
- Detect collisions between objects.
- Destroy objects when collisions occur.
- Display information using the Draw GUI event.
- Use conditional statements.
- Understand basic game-state logic.
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:
| Object | Sprite |
|---|---|
obj_player | spr_player |
obj_bullet | spr_bullet |
obj_enemy | spr_enemy |
obj_controller | No Sprite |
The controller object will manage:
- Score
- Enemy creation
- Game Over
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:
- The player receives 10 points.
- The enemy is destroyed.
- 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:
obj_playerobj_controller
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:
- Player spaceship
- Arrow-key movement
- Spacebar shooting
- Bullets
- At least one enemy type
- Random enemy spawning
- Enemy movement
- Bullet/enemy collision
- Enemy destruction
- Player/enemy collision
- Player health
- Score
- Health displayed on screen
- Score displayed on screen
- Game Over screen
- Ability to restart the game
Required Controls
| Control | Action |
|---|---|
| Left Arrow | Move Left |
| Right Arrow | Move Right |
| Up Arrow | Move Up |
| Down Arrow | Move Down |
| Spacebar | Shoot |
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.
- Player moves left.
- Player moves right.
- Player moves up.
- Player moves down.
- Player cannot leave the room.
- Spacebar fires bullets.
- Bullets move upward.
- Bullets disappear after leaving the screen.
- Enemies appear randomly.
- Enemies move downward.
- Bullets destroy enemies.
- Destroying an enemy increases the score.
- Enemies damage the player.
- Health decreases correctly.
- Health appears on the screen.
- Score appears on the screen.
- Game ends when health reaches zero.
- Game Over screen appears.
- Player can restart the game.
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:
- Shooting
- Enemy destruction
- Player damage
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:
- Basic enemy
- Fast enemy
- Large enemy
- Shooting enemy
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:
- At least 100 health
- Multiple attacks
- Movement pattern
- Health bar
- Higher point value
Submission Requirements
Submit the following:
1. GameMaker Project
Project name:
PX_Lastname_SpaceShooter
2. Screenshot
Submit a screenshot showing:
- Player
- Enemies
- Bullets
- Health
- Score
3. Gameplay Video
Record at least:
10 seconds
The video must show:
- Player movement
- Shooting
- Enemy movement
- At least one enemy being destroyed
- Score changing
4. Google Classroom
Upload all required files to the assignment in Google Classroom.
Grading Rubric
| Requirement | Points |
|---|---|
| Player movement works | 10 |
| Player stays inside room | 5 |
| Shooting works | 10 |
| Bullets move correctly | 5 |
| Enemies spawn | 10 |
| Enemies move correctly | 5 |
| Bullet/enemy collision works | 10 |
| Score system works | 10 |
| Player health works | 10 |
| Player/enemy collision works | 10 |
| Health and score displayed | 5 |
| Game Over system works | 5 |
| Game can restart | 5 |
| Total | 100 |
Concepts Used
This project demonstrates:
- Variables
- Objects
- Sprites
- Events
- Keyboard input
- Conditionals
- Collision detection
- Object creation
- Object destruction
- Random numbers
- Alarms
- Health systems
- Score systems
- GUI drawing
- Game states
Final Goal
When finished, your game should function like a basic arcade Space Shooter:
Move → Shoot → Destroy Enemies → Earn Points → Avoid Enemies → Stay Alive