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:
- The graphics are defined in the
assets.js
file, but we will add more logic to the sprite with theenergy.js
file:;(function(game, cjs, lib){ function Energy(x, y) { cjs.Container.call(this); //super this.addChild(new lib.Energy()); this.cache(-25, -25, 50, 50); // cache the bitmap to improve...