Any
mechanic

how to build it without the perfect tutorial

$ make game

$ search "wall jump tutorial but you're a frog and it's raining and the walls are sticky"

0 results.

There is no tutorial
for your game

If there were one,
your game would already exist.

A recipe

Pancakes, step by step.

Works for pancakes. Only pancakes.

Knowing how to cook

Heat, mix, fry, season.

Works for pancakes, and for dishes nobody wrote down yet.

Every mechanic is a few
small, boring pieces
stuck together.

Ask four questions
about any mechanic.

1. Remember

What does the game need to keep track of?

a number, a yes/no, a position, a list

2. When

What makes it happen?

a button, a timer, a touch, being close

3. Do

What changes when it happens?

move, add, remove, switch state

4. Show

How does the player notice?

a sound, a flash, a number, a shake

Describe a double jump
in one sentence.

When I press jump while in the air, and I still have a jump left, I jump again. Landing gives it back.

When I press jump while in the air, and I still have a jump left, I jump again. Landing gives it back.

rememberjumps left → a number

When I press jump while in the air, and I still have a jump left, I jump again. Landing gives it back.

rememberjumps left → a number
whenpressed, in the air, landed → ifs

When I press jump while in the air, and I still have a jump left, I jump again. Landing gives it back.

rememberjumps left → a number
whenpressed, in the air, landed → ifs
dojump, give it back → set velocity, set the number

Then it's just code


// remember
var jumpsLeft = 1

// when: jump pressed, in the air, a jump left
if (pressed('jump') && !onGround && jumpsLeft > 0) {
    // do
    velocity.y = -JUMP_SPEED
    jumpsLeft -= 1
}

// when: landed / do: give it back
if (onGround) {
    jumpsLeft = 1
}
                

Your turn: dash

When I press dash, and the cooldown is over, I shoot forward for a moment.

Your turn: dash

When I press dash, and the cooldown is over, I shoot forward for a moment.

remembertwo timers
whena button, a timer at zero
doset velocity

The toolbox

variable

remember a number, a yes/no, a name

condition

only if this is true

timer

a number that counts down

input

pressed, held, or let go?

velocity

move a bit every frame

acceleration

change velocity every frame

vectors

how far, and which way?

overlap

are these two touching?

raycast

shoot a line, what does it hit?

state

what mode am I in right now?

spawn

make a thing, destroy a thing

list

many of the same thing

signal

tell others something happened

random

pick one, roll a dice

lerp

move part of the way there

A D move · W or space jump · shift dash · turn the blocks on one by one

Each piece is easy.
Combining them
is the hard part.

shift dash · A D move · W jump

After every new piece,
play everything again.

Pick a mechanic

variable

condition

timer

input

velocity

acceleration

vectors

overlap

raycast

state

spawn

list

signal

random

lerp

Click a mechanic.

Flags everywhere


if (pressed('jump') && !isJumping) isJumping = true
if (pressed('down') && onGround)   isDucking = true
if (pressed('down') && isJumping)  isDiving  = true
                

Jumping and ducking?

The piece people miss:
state

An enemy that patrols, chases,
attacks and gives up is
four small enemies taking turns.

move the mouse in the room · the guard only sees what is close, in front, and not behind a wall

The whole guard


var state = 'patrol'

if (state == 'patrol') {
    walkTo(nextWaypoint)
    if (canSee(player)) state = 'chase'
}
else if (state == 'chase') {
    lastSeen = player.position
    walkTo(player.position)
    if (distanceTo(player) < 30) state = 'attack'
    else if (!canSee(player)) state = 'search'
}
else if (state == 'attack') {
    hit(player)
    if (attackDone) state = 'chase'
}
else if (state == 'search') {
    walkTo(lastSeen)
    lookAround()
    if (canSee(player)) state = 'chase'
    else if (searchTimer <= 0) state = 'patrol'
}
                

From idea to code

  1. Say it in one sentence. no code yet
  2. Ask the four questions. remember, when, do, show
  3. Match each part to a block. the toolbox
  4. Write it as comments first. then fill them in
  5. Build the ugliest version. squares, no art
  6. Tune the numbers until it feels right.

Comments first


// dash:
// when I press dash and the cooldown is over
//     remember: dash time = 0.15 s, cooldown = 0.6 s
//     do: move fast in the way I'm facing, no gravity
// every frame: count both timers down
// show: a trail behind me, a whoosh
                

Feel lives in the numbers


const JUMP_SPEED  = 620    // px per second
const GRAVITY     = 1800
const COYOTE_TIME = 0.1    // seconds
const DASH_TIME   = 0.15
const DASH_SPEED  = 700
                

Give every number a name.
Then play, change one, play again.

Games cheat

  1. Jump after you've left the ledge.
  2. Press jump too early, still jump.
  3. Bump a corner, slide past it.
  4. Wall jump from 2 pixels away.

Celeste & Forgiveness — Maddy Thorson

When you're stuck

  1. Make it smaller. the piece you're on is still too big
  2. Print what the game remembers. like the numbers in the corner
  3. Search the piece. engine docs first
  4. Explain it out loud. to a friend, or a rubber duck

Watch tutorials to steal
the pieces, not the recipe.

First: change it

  1. Double jump → triple jump.
  2. Wall slide → wall jump.
  3. Dash → dash with no cooldown.

Your turn

press roll

in pairs: one sentence → four questions → list the blocks → build it with squares in 30 minutes

You don't need a tutorial
for your mechanic.

You need the pieces,
and the questions that split it.

Questions?

Now build
anything

$ exit