O'Reilly logo

HTML5 Game Development HOTSHOT by Makzan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating energy

We need energy to build the buildings. In this task, we generate energy for each satellite built on the board.

Prepare for lift off

Before we start this task, we need to revert the game parameters that we temporarily changed in the previous section. In the game.js file, we set the initial lives to 20 and the energies to 120:

game.lives = 20;
game.energies = 120;

We have the new display object, an energy bubble, which can be collected when it is generated by satellites. Add the energy.js file to the board-objects folder and include it into the HTML:

<script src="scripts/board-objects/energy.js"></script>

Engage thrusters

Let's work on energy generation:

  1. The graphics are defined in the assets.js file, but we will add more logic to the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required