Workshop › Doodle Jump-style Climber › Step 10 of 24
A platform catches the player only on the way down, and only when the feet cross its top during this frame. So you can jump up through a platform from below and land on it on the way down, just like the real game.
```js
const oldBottom = player.y + player.h
player.vy += GRAVITY
player.y += player.vy
const bottom = player.y + player.h
// Platforms only catch you on the way down, when your feet cross their top in this frame.
if (player.vy > 0) {
for (const p of platforms) {
const over = player.x + player.w - 8 > p.x && player.x + 8 < p.x + p.w
if (over && oldBottom <= p.y && bottom >= p.y) {
player.y = p.y - player.h
player.vy = JUMP
break
}
}
}
// For now the floor still bounces you back up.
```oldBottom and bottom are the feet before and after this frame's move.vy > 0 means falling. over checks the player is above the platform sideways (8 pixels of each side do not count).oldBottom <= p.y) and at or below it now.break stops looking at other platforms.update, write oldBottom above the gravity lines and bottom under them.Skills: Collision detection
← Platforms A camera that follows →