mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
fixes #12 and added health
This commit is contained in:
parent
6c78c750f0
commit
d84fb20f90
7 changed files with 83 additions and 18 deletions
|
|
@ -117,6 +117,16 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
|||
|
||||
};
|
||||
|
||||
GameController.prototype.onUpdateStats = function(options) {
|
||||
var player = this.players[options.playerId];
|
||||
player.stats = options.stats;
|
||||
|
||||
// FIXME: move to canvas later
|
||||
if(player == this.me) {
|
||||
DomController.setHealth(player.stats.health);
|
||||
}
|
||||
};
|
||||
|
||||
GameController.prototype.loadLevel = function (path) {
|
||||
Parent.prototype.loadLevel.call(this, path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,13 @@ function (Settings, NotificationCenter, Stats, Screenfull) {
|
|||
label.appendChild(checkbox);
|
||||
label.appendChild(document.createTextNode("Debug"));
|
||||
this.devToolsContainer.appendChild(label);
|
||||
|
||||
// create health
|
||||
this.health = document.createElement("span");
|
||||
this.health.innerHTML = "Health: 100";
|
||||
p = document.createElement("p");
|
||||
p.appendChild(this.health);
|
||||
this.devToolsContainer.appendChild(p);
|
||||
};
|
||||
|
||||
DomController.prototype.statsBegin = function() {
|
||||
|
|
@ -133,6 +140,10 @@ function (Settings, NotificationCenter, Stats, Screenfull) {
|
|||
return this.debugCanvas;
|
||||
}
|
||||
|
||||
DomController.prototype.setHealth = function(health) {
|
||||
this.health.innerHTML = "Health: " + parseInt(health, 10);
|
||||
};
|
||||
|
||||
|
||||
return new DomController();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue