Workshop › Doodle Jump-style Climber › Step 3 of 24
The player gets a vertical speed vy. Every frame gravity adds to it and the speed moves the player, so it falls
faster and faster, until its feet reach the floor.
```js
const GRAVITY = 0.35
const FLOOR = 600 // the bottom of the canvas
let player = { x: 180, y: 460, w: 40, h: 40, vy: 0 }
function update() {
player.vy += GRAVITY
player.y += player.vy
if (player.y + player.h >= FLOOR) {
player.y = FLOOR - player.h
player.vy = 0
}
}
update()
```vy is pixels per frame downward (negative is up). Gravity adds 0.35 every frame.y + h; once they reach the floor, the player is put on it and stops.ctx, write GRAVITY and FLOOR; add , vy: 0 to player.player, write update; call it in loop before draw().Skills: Velocity and gravity
← Draw again and again Bounce →