Workshop › Asteroids › Step 31 of 41
The player must see that the ship is safe, or rocks passing through it look like a bug. So a safe ship blinks: it is drawn only in every other 150 ms slice of time.
```js
// Blink while invulnerable, so the player can see it.
const safe = now < ship.safeUntil
if (!safe || Math.floor(now / 150) % 2 === 0) drawShip()
```safe is true while the safe time is not over.Math.floor(now / 150) is the number of the 150 ms slice; % 2 === 0 is true for every other slice.|| means "or": draw the ship when it is not safe, or in an even slice.In draw, replace the drawShip() line with the comment and the two new lines.
Skills: Drawing on a canvas, Game states
← A moment of safety Waves of rocks →