๐ŸŽฏ My First GameMaker Game ยท Episode 2 of 5 ยท See All Episodes
๐Ÿƒ Episode 2 ยท Beginner+ ยท The GameMaker Classic

Run & Jump!
GML Platformer

THE GameMaker genre: pixel-perfect platforming with place_meeting collision, gravity, coyote-time jumping, tile-decorated rooms and a camera that follows, the exact recipe behind countless indie hits.

๐Ÿ‘ถ Ages 10+ โฑ๏ธ ~2 Hours ๐ŸŽฏ GameMaker โœ“ Free
๐ŸŒ Gravity in GML ๐Ÿงฑ place_meeting ๐Ÿฆ˜ Jump & coyote time ๐ŸŽฅ Camera & views ๐Ÿช™ Coins ๐Ÿšฉ Level goal
โญ
0 XP
Level 1
๐Ÿ”ฅ0
Your Progress 0 / 6 steps
1
๐Ÿงฑ
Player, Wall & the Grid
Set up obj_player, obj_wall and a test room
Active
๐ŸŽฏ
Goal for this step

Create the player and solid wall objects and lay out a room.

  • 1New project. Sprites: spr_player (32ร—48, orange) and spr_wall (32ร—32, green). Objects: obj_player, obj_wall.
  • 2IMPORTANT: on spr_player set the origin to Middle Centre, collision maths gets much saner.
  • 3In the room editor, enable grid snap 32 and paint a floor plus some ledges from obj_wall instances.
  • 4Create event of obj_player: the movement variables below. No motion yet, foundations first.
obj_player ยท Create
move_speed = 4;
jump_force  = -11;
grav        = 0.5;
vsp = 0;    // vertical speed
hsp = 0;    // horizontal speed
โœ๏ธ
Fill in the Blanks
+15 XP
Solid level pieces are instances of obj_. The sprite is set to Middle Centre so position maths stays simple. Room grid snapping was set to .
๐Ÿง 
Knowledge Check
+15 XP
Why do we use OUR OWN hsp/vsp instead of the built-in hspeed/vspeed here?
AThe built-ins are broken
BWe need to test collisions BEFORE applying movement, manual variables give us that control
CThey are faster to type
2
๐Ÿšถ
place_meeting Movement
The most famous 10 lines in GameMaker
Locked
๐ŸŽฏ
Goal for this step

Implement collision-safe horizontal and vertical movement.

  • 1place_meeting(x, y, obj) asks: "if I stood at this position, would I overlap that object?", collision BEFORE moving. This is GameMakerโ€™s crown jewel.
  • 2The pattern: compute hsp from input; if the spot ahead is blocked, inch up to the wall pixel-by-pixel then zero the speed; else move.
  • 3Same for vertical with gravity added to vsp first.
  • 4This exact Step code is in thousands of shipped games. Learn it by heart.
obj_player ยท Step
var key_left  = keyboard_check(vk_left);
var key_right = keyboard_check(vk_right);
hsp = (key_right - key_left) * move_speed;
vsp += grav;

// horizontal
if (place_meeting(x + hsp, y, obj_wall)) {
    while (!place_meeting(x + sign(hsp), y, obj_wall)) x += sign(hsp);
    hsp = 0;
}
x += hsp;

// vertical
if (place_meeting(x, y + vsp, obj_wall)) {
    while (!place_meeting(x, y + sign(vsp), obj_wall)) y += sign(vsp);
    vsp = 0;
}
y += vsp;
โŒจ๏ธ
Code Challenge
+20 XP
Complete the pixel-perfect horizontal block:
obj_player ยท Step
if ((x + hsp, y, obj_wall)) {
    while (!place_meeting(x + (hsp), y, obj_wall)) x += sign(hsp);
    hsp = ;
}
๐Ÿ’ก Hint: The look-ahead test; then creep one pixel at a time in the movement direction until flush; then stop.
๐Ÿง 
Knowledge Check
+15 XP
The while-loop that inches toward the wall gives youโ€ฆ
ASlower movement
BPixel-perfect landing flush against walls, no gaps, no overlaps, at any speed
CWall destruction
3
๐Ÿฆ˜
Jumping & Coyote Time
Grounded checks plus the forgiveness timer
Locked
๐ŸŽฏ
Goal for this step

Add jumping with the pro-level coyote-time polish.

  • 1Grounded test: place_meeting(x, y + 1, obj_wall), is there floor one pixel below?
  • 2Track coyote frames: reset to 6 when grounded, count down in air; jump allowed while > 0.
  • 3(6 frames = 0.1 s at 60 fps, the same window you built in C++. Same design, new engine.)
  • 4Also add jump buffering: remember a jump press for 6 frames so pressing JUST before landing still jumps. The two timers together = jumps that feel psychic.
obj_player ยท Step (additions)
var on_ground = place_meeting(x, y + 1, obj_wall);
if (on_ground) coyote = 6; else coyote--;

if (keyboard_check_pressed(vk_space)) buffer = 6; else buffer--;

if (buffer > 0 && coyote > 0) {
    vsp = jump_force;
    coyote = 0;
    buffer = 0;
}
โœ๏ธ
Fill in the Blanks
+15 XP
The grounded check looks one pixel the player. Coyote time forgives late jumps; jump forgives early ones. Both timers run about frames.
๐Ÿง 
Knowledge Check
+15 XP
Jump buffering handles the case where the player presses jumpโ€ฆ
ATwice quickly
BSlightly BEFORE landing, the press is remembered and fires on touchdown instead of being eaten
CWhile paused
4
๐ŸŽฅ
Camera & A Bigger World
Viewports that follow the player smoothly
Locked
๐ŸŽฏ
Goal for this step

Expand the room and set up a smooth-follow camera.

  • 1Resize the room to 2400ร—500 and build a longer level.
  • 2Room editor โ†’ Viewports: enable Viewport 0, camera 800ร—500.
  • 3Smooth-follow beats hard-lock: lerp the camera toward the player each Step in obj_game.
  • 4lerp(a, b, 0.1) moves a tenth of the way per frame, smooth chase, no snapping. Clamp inside the room.
obj_game ยท Step
var cam = view_camera[0];
var cx = camera_get_view_x(cam);
var target = clamp(obj_player.x - 400, 0, room_width - 800);
camera_set_view_pos(cam, lerp(cx, target, 0.1),
                    camera_get_view_y(cam));
โŒจ๏ธ
Code Challenge
+20 XP
Smooth-follow the player:
obj_game ยท Step
var target = clamp(obj_player.x - , 0, room_width - 800);
camera_set_view_pos(cam, (cx, target, 0.1), camera_get_view_y(cam));
๐Ÿ’ก Hint: Centre an 800-wide view on the player; the smoothing function blends a fraction toward the target each frame.
๐Ÿง 
Knowledge Check
+15 XP
lerp(cx, target, 0.1) each frame producesโ€ฆ
AInstant snapping
BAn easing chase, fast when far, gentle when close, like a cameraman
CA shaking camera
5
๐Ÿช™
Coins, Spikes & Respawn
Pickups and hazards, GameMaker style
Locked
๐ŸŽฏ
Goal for this step

Add collectable coins and deadly spikes with a respawn.

  • 1obj_coin: gold sprite; a Collision event with obj_player runs instance_destroy() and global.coins++, pickups in two lines!
  • 2obj_spike: red triangle sprite; its collision with the player moves the player to global respawn coordinates.
  • 3Store the respawn in obj_game create (global.rx / global.ry), draw coin count in Draw GUI.
  • 4Feel the engine difference: what took loops and lists in Python is one visual event here, engines trade control for speed.
obj_coin ยท Collision with obj_player
global.coins += 1;
instance_destroy();

// obj_spike ยท Collision with obj_player:
other.x = global.rx;
other.y = global.ry;
other.vsp = 0;
โœ๏ธ
Fill in the Blanks
+15 XP
A pickup deletes itself with (). Inside the spikeโ€™s collision event, refers to the player who touched it.
๐Ÿง 
Knowledge Check
+15 XP
In obj_spikeโ€™s collision event, why is the player "other"?
APlayers are always other
BThe event belongs to the spike, self is the spike, other is whoever collided with it
CA GML quirk
6
๐Ÿšฉ
The Goal & Multiple Rooms
Level exits, room flow and the finish line
Locked
๐ŸŽฏ
Goal for this step

Add a goal flag that advances rooms, and finish the game.

  • 1obj_flag: collision with the player โ†’ room_goto_next(), GameMaker rooms ARE your level system, built in.
  • 2Build rm_level2 (copy rm_level1, redesign). Order rooms in the asset browser, that IS the level order.
  • 3Last room: rm_win with a victory object (coins collected, R to restart via room_goto(rm_level1) + reset globals).
  • 4Set global.rx/ry per room in a Room Start event so respawns follow the level.
  • 5Two-level platformer with camera, coins, hazards: shipped. Episode 3 goes arcade!
obj_flag ยท Collision with obj_player
if (room != room_last) {
    room_goto_next();
} else {
    room_goto(rm_win);
}
โœ๏ธ
Fill in the Blanks
+15 XP
Advancing a level is one call: (). The room order in the asset defines the level order.
๐Ÿง 
Knowledge Check
+15 XP
GameMaker rooms map naturally ontoโ€ฆ
ASave files
BLevels/screens, the engine gives you a level system for free where other tools needed load functions
CSprites
๐ŸŽ‰๐Ÿ†๐ŸŽฎโœจ๐ŸŽ‰
Workshop Complete!
Pixel-perfect collision and a following camera, the true GameMaker platformer core. Episode 3: Breakout with juice!
0
Total XP
1
Level
0
Best Streak
0%
Accuracy
โ–ถ Episode 3: Breakout โ†’
โญ View My Progress & Certificates

This workshop was free and took many hours to build. If it helped you learn something new, consider supporting the project.

☕ Support on Ko-fi