Workshop › Flappy-style Bird › Step 17 of 30
We count the frames of play in frame. Every 90 frames (one and a half seconds) a new pipe is added. The remainder
operator % tells when: frame % 90 === 0 is true on frames 90, 180, 270...
```js
const PIPE_EVERY = 90 // frames between new pipes
let frame = 0
frame += 1
if (frame % PIPE_EVERY === 0) addPipe()
```frame counts the frames of play; update adds 1 each time.% is the remainder: frame % PIPE_EVERY is 0 only when frame is a multiple of 90.addPipe() puts a new pipe at the right edge, and the loop below slides it left.PIPE_SPEED, write PIPE_EVERY.let pipes = [], write let frame = 0.update, above the pipe loop, write the two frame lines.Skills: The game loop
← A new pipe at a random height Remove the pipes you passed →