$ 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.
Landinggives it back.
When I press jump while in the air,
and I still have a jump left, I jump again.
Landinggives it back.
remember
jumps left → a number
When I press jump while in the air,
and I still have a jump left, I jump again.
Landinggives it back.
remember
jumps left → a number
when
pressed, in the air, landed → ifs
When I press jump while in the air,
and I still have a jump left, I jump again.
Landinggives it back.
remember
jumps left → a number
when
pressed, in the air, landed → ifs
do
jump, 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.
remember
two timers
when
a button, a timer at zero
do
set 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
Say it in one sentence. no code yet
Ask the four questions. remember, when, do, show
Match each part to a block. the toolbox
Write it as comments first. then fill them in
Build the ugliest version. squares, no art
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