Workshop › Lunar Lander › Step 12 of 31
When a foot (or the middle) reaches the ground under it, the lander stops. For now every touch counts as a crash; the rules of a good landing come later.
```js
function touchdown() {
state = 'crashed'
}
const feet = lander.y + 10
if (feet >= groundY(lander.x - FEET) || feet >= groundY(lander.x) || feet >= groundY(lander.x + FEET)) touchdown()
```feet is the y of the bottom of the feet.groundY gives the ground's height under the left foot, the middle and the right foot. >= means the feet reached
it (y grows downward); || means any one of the three is enough.touchdown() sets the state to 'crashed', so update stops moving the lander.touchdown just above function update() {, with an empty line between.update, leave an empty line and write the two feet lines.Skills: Collision detection
← Flying or not Remember held keys →