HTML and CSS Reference
In-Depth Information
We defined BuildingsData in the previous task. Now, we add one more parameter to
each building's data. The new parameter is the duraion in seconds that each construcion
step takes:
game.BuildingsData['CoinsGenerator'] = {
...
// existing building data goes here.
stepsSeconds: [10, 20]
};
game.BuildingsData['PowerSupply'] = {
...
// existing building data goes here.
stepsSeconds: [5, 10]
};
game.BuildingsData['Merchant'] = {
// existing building data goes here.
stepsSeconds: [20, 40]
};
We added two images and now we insert the following code inside the sprite-view.js
file to make it available for the city drawing code to use:
(game.ConstructionStep1 = function() {
game.Tile.call(this, 'images/construction-step1.png');
this.regX = 0;
this.regY = 51;
}).prototype = Object.create(game.Tile.prototype);
(game.ConstructionStep2 = function() {
game.Tile.call(this, 'images/construction-step2.png');
this.regX = 0;
this.regY = 74;
}).prototype = Object.create(game.Tile.prototype);
Engage thrusters
In the following steps, we will add the construcion logic to the building:
1. We add several properies to count the growing statuses inside the Building
funcion constructor:
game.Building = function(isoX, isoY, viewClassName) {
...
// existing Building code goes here.
this.isConstructionDone = false;
 
Search WWH ::




Custom Search