Workshop › Asteroids › Step 17 of 41
The game starts with four big rocks on the top edge, away from the ship in the middle. Each one's x is either 0 or a
random point across the width, 50/50.
```js
let asteroids
asteroids = []
for (let i = 0; i < 4; i++) asteroids.push(makeAsteroid(Math.random() < 0.5 ? 0 : Math.random() * canvas.width, 0, 3))
```y = 0.Math.random() < 0.5 ? 0 : ... is a coin toss: half the time 0, otherwise a random x.let bullets write let asteroids.bullets = [], write the two lines.Skills: Arrays and objects, Loops
← Making a rock Drawing the rocks →