GameMaker Project: Move the Player

Beginner GameMaker Assignment

Name: ________________________________     Period: ________

Your Goal

Your job is to create a GameMaker project where a player can move around the screen using the arrow keys.

By the end of this assignment, you should be able to move your player left, right, up, and down.

What You Will Learn

Project Requirements

Item Name or Setting
Room rm_game
Player Sprite spr_player
Player Object obj_player
Movement Speed 4
Controls Arrow Keys

Step 1: Create Your Project

  1. Open GameMaker.
  2. Create a new game project.
  3. Name the project PX_lastname_MoveThePlayer.
  4. Make sure you are creating a 2D GameMaker project.

Step 2: Create the Player Sprite

  1. Create a new sprite.
  2. Name it spr_player.
  3. Draw a simple square, circle, character, or other shape.
  4. Save the sprite.
Tip: Your sprite does not need to look fancy. A simple colored square is fine.

Step 3: Create the Player Object

  1. Create a new object.
  2. Name it obj_player.
  3. Assign spr_player as its sprite.

Step 4: Add the Step Event

Add a Step Event to obj_player.

Enter the following code:

// Player movement speed
var move_speed = 4;

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

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

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

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

Step 5: Create the Room

  1. Create a new room.
  2. Name it rm_game.
  3. Use a room size close to:
Width: 960
Height: 540
  1. Drag obj_player into the room.
  2. Place the player near the center of the room.

Step 6: Test Your Game

Run the game and test each key.

Key What Should Happen?
Left Arrow Player moves left
Right Arrow Player moves right
Up Arrow Player moves up
Down Arrow Player moves down

How the Movement Code Works

GameMaker uses the player's x and y position to decide where the player appears on the screen.

Code What It Does
x -= move_speed; Moves left
x += move_speed; Moves right
y -= move_speed; Moves up
y += move_speed; Moves down
Remember: In GameMaker, smaller Y values move an object upward and larger Y values move an object downward.

Student Checklist

Challenge Activities

Finish the basic assignment first. Then try one or more of these:

Final Result

When you are finished, you should have a simple game where the player appears on the screen and moves in four directions using the arrow keys.

This movement system will be used later in larger games such as maze games, collection games, adventure games, and top-down games.