Workshop › Missile Command-style Defense › Step 31 of 35
Soon some missiles will split in the air. The pieces must start where the missile is, not at the top. So launch gets
a starting point, with the top edge as the default.
```js
function launch(sx = Math.random() * canvas.width, sy = 0) {
incoming.push({ sx, sy, x: sx, y: sy, tx, ty: GROUND, speed: 0.5 + wave * 0.15 })
```sx = ... and sy = 0 are default parameters: used only when launch is called without them.launch() still makes a normal missile at the top; launch(100, 150) starts one at (100, 150).const sx line is no longer needed.launch line as shown and delete the const sx = ... line under it.push line, use sy instead of sy: 0, and y: sy instead of y: 0.Skills: Functions
← Wave, ammo and messages Some missiles will split →