Workshop › Frogger-style Crossing › Step 14 of 22
The river is deadly: in a log lane, the frog must stand on a log, which means its middle must be over one. Otherwise it falls in the water.
```js
function onLog(lane) {
const middle = frog.x + 0.5
return items(lane).some((x) => middle > x && middle < x + lane.len)
}
if (!lane.log) {
if (hitByCar(lane)) die()
return
}
if (!onLog(lane)) {
die()
return
}
```middle is the middle of the frog's square; it must be between a log's two ends.update, write onLog.update, split the check for road and river as shown.Skills: Collision detection
← Logs on the river Ride the log →