mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
replaced killed doll with ragdoll - fixes #50
This commit is contained in:
parent
aa6fdaa2df
commit
413254bfa4
19 changed files with 330 additions and 88 deletions
|
|
@ -25,7 +25,6 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
|||
|
||||
GameController.prototype = Object.create(Parent.prototype);
|
||||
|
||||
|
||||
GameController.prototype.destruct = function() {
|
||||
//destroy box2d world etc.
|
||||
};
|
||||
|
|
@ -35,6 +34,9 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
|||
}
|
||||
|
||||
GameController.prototype.update = function () {
|
||||
|
||||
Parent.prototype.update.call(this);
|
||||
|
||||
DomController.statsBegin();
|
||||
|
||||
requestAnimFrame(this.update.bind(this));
|
||||
|
|
@ -45,10 +47,6 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
|||
this.me.update();
|
||||
}
|
||||
|
||||
for (var key in this.players) {
|
||||
this.players[key].render();
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.gameObjects.animated.length; i++) {
|
||||
this.gameObjects.animated[i].render();
|
||||
}
|
||||
|
|
@ -97,7 +95,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
|||
|
||||
var player = this.players[playerId];
|
||||
player.spawn(x, y);
|
||||
this.gameObjects.animated.push(player.getDoll());
|
||||
this.gameObjects.animated.push(player);
|
||||
|
||||
if(options.holdingItemUid) {
|
||||
this.onHandActionResponse({
|
||||
|
|
@ -148,18 +146,26 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
|||
player.kill(killedByPlayer);
|
||||
};
|
||||
|
||||
GameController.prototype.onRemoveGameObject = function(options) {
|
||||
var object = null;
|
||||
for (var i = 0; i < this.gameObjects[options.type].length; i++) {
|
||||
if(this.gameObjects[options.type][i].uid == options.uid) {
|
||||
object = this.gameObjects[options.type][i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(object) {
|
||||
this.onGameObjectRemove(options.type, object);
|
||||
object.destroy();
|
||||
} else {
|
||||
console.warn("GameObject for removal can not be found locally. " + options.uid);
|
||||
}
|
||||
};
|
||||
|
||||
GameController.prototype.loadLevel = function (path) {
|
||||
Parent.prototype.loadLevel.call(this, path);
|
||||
}
|
||||
|
||||
GameController.prototype.userLeft = function(user) {
|
||||
var doll = this.players[user.id].doll;
|
||||
var i = this.gameObjects.animated.indexOf(doll);
|
||||
if(i>=0) this.gameObjects.animated.splice(i, 1);
|
||||
|
||||
Parent.prototype.userLeft.call(this, user);
|
||||
}
|
||||
|
||||
GameController.prototype.toggleInfo = function(show) {
|
||||
|
||||
var playersArray = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue