Workshop › Tower Defense › Step 30 of 42
Stronger every wave
What we are doing
The same enemies every wave get boring. Each wave's enemies get 25% more health than the wave before.
```js
function enemyHp() {
return Math.round(10 * 1.25 ** (wave - 1))
}
const hp = enemyHp()
enemies.push({ d: 0, hp, maxHp: hp })
```
What it means
** is "to the power of": 1.25 ** 2 is 1.25 × 1.25. Wave 1 has 10 hp, wave 2 12.5, wave 3 about 15.6...
Math.round rounds to a whole number.
{ d: 0, hp, maxHp: hp }: writing just hp is short for hp: hp.
Your turn
- Under the
startWave function, write enemyHp.
- In
update, replace the enemies.push({ d: 0, hp: 10, maxHp: 10 }) line with the two new lines.
Skills: Game states
← The wave is over Closer together →
All steps
- Measure the map
- A map of tiles
- Draw it every frame
- The road as corners
- Fill in the road
- Draw the road
- Walking by distance
- Enemies on the road
- Walk
- Off the end of the road
- Here they come
- Towers
- From a click to a tile
- Click to build
- Where can you build?
- Show the gold
- Show before you click
- Show the range
- Pick a target
- Fire!
- A hit hurts
- Homing bullets
- Fizzle out
- Gold for every kill
- Lives
- Health bars
- Build, then defend
- Space starts a wave
- The wave is over
- Stronger every wave
- Closer together
- Out of lives
- No building after the end
- The most waves survived
- The game over screen
- Play again
- The bottom bar
- Click to start
- A second tower: the cannon
- Tower buttons
- Splash damage
- Build it yourself: sell a tower