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
- How to create a GameMaker project.
- Your project name is PX_lastname_player.
- Your project needs to be saved under under 2026_27KleinCollins\your class name
- Create 2 files:
- file one: PX_lastname_Player.png (Screen print of the program inside the game maker ide)
- file two: PX_lastname_Player.mp4 (Video of you playing the game. I need at least 7 seconds)
- Be sure to drop off the two file into your google drive for class under 2026_27KleinCollins\your class name
- Drop your two files into google classroom.
- How to create a sprite.
- How to create an object.
- How to place an object in a room.
- How to use the Step Event.
- How to detect keyboard input.
- How to change the player's position.
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
- Open GameMaker.
- Create a new game project.
- Name the project PX_lastname_Player.
- Make sure you are creating a 2D GameMaker project.
Step 2: Create the Player Sprite
- Create a new sprite.
- Name it
spr_player.
- Draw a simple square, circle, character, or other shape.
- Save the sprite.
Tip:
Your sprite does not need to look fancy. A simple colored square is fine.
Step 3: Create the Player Object
- Create a new object.
- Name it
obj_player.
- 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
- Create a new room.
- Name it
rm_game.
- Use a room size close to:
Width: 960
Height: 540
- Drag
obj_player into the room.
- 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
- ☐ My game starts without errors.
- ☐ My player appears on the screen.
- ☐ My player moves left.
- ☐ My player moves right.
- ☐ My player moves up.
- ☐ My player moves down.
- ☐ My player continues moving while I hold a key.
- ☐ My project is saved.
Challenge Activities
Finish the basic assignment first. Then try one or more of these:
- Change the movement speed from 4 to 6.
- Add WASD controls.
- Change the player's sprite.
- Change the room background.
- Keep the player from leaving the room.
- Add an obstacle.
- Add collision detection.
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.