This commit is contained in:
Jeena 2014-02-10 22:22:14 +01:00
parent 89c5e4a5d8
commit ed23753c04
17 changed files with 286 additions and 224 deletions

View file

@ -156,6 +156,10 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
this.setActionState("fall");
}
Doll.prototype.kill = function() {
this.body.SetFixedRotation(false);
};
Doll.prototype.getPosition = function() {
var pos = this.body.GetPosition();
return {

View file

@ -19,8 +19,8 @@ function (Parent, Box2D, Settings, Exception) {
var bodyDef = new Box2D.Dynamics.b2BodyDef();
bodyDef.type = Box2D.Dynamics.b2Body.b2_staticBody;
bodyDef.position.x = this.options.x * Settings.TILE_SIZE / Settings.RATIO;
bodyDef.position.y = this.options.y * Settings.TILE_SIZE / Settings.RATIO;
bodyDef.position.x = (this.options.x * Settings.TILE_SIZE + Settings.TILE_SIZE / 2) / Settings.RATIO;
bodyDef.position.y = (this.options.y * Settings.TILE_SIZE + Settings.TILE_SIZE / 2) / Settings.RATIO;
bodyDef.angle = (this.options.r || 0) * 90 * Math.PI / 180;
return bodyDef;

View file

@ -36,45 +36,58 @@ function (Doll, Settings, NotificationCenter) {
}
Player.prototype.getPosition = function () {
if(!this.doll) return false;
return this.doll.getPosition();
}
Player.prototype.getHeadPosition = function () {
if(!this.doll) return false;
if(!this.isSpawned) return false;
return this.doll.getHeadPosition();
}
Player.prototype.move = function (direction) {
if(!this.isSpawned) return false;
this.doll.move(direction);
}
Player.prototype.stop = function () {
if(!this.isSpawned) return false;
this.doll.stop();
}
Player.prototype.jump = function () {
if(!this.isSpawned) return false;
this.doll.jump();
}
Player.prototype.lookAt = function (x, y) {
if(this.doll) this.doll.lookAt(x, y);
if(!this.isSpawned) return false;
this.doll.lookAt(x, y);
}
Player.prototype.grab = function(item) {
if(!this.isSpawned) return false;
item.beingGrabbed(this);
this.doll.grab(item);
this.holdingItem = item;
};
Player.prototype.throw = function(x, y, item) {
if(!this.isSpawned) return false;
item.beingReleased(this);
this.doll.throw(item, x, y);
this.holdingItem = null;
};
Player.prototype.kill = function(killedBy) {
if(!this.isSpawned) return false;
// FIXME: do something better then just respawn in GameController
if(this.holdingItem) {
this.throw(0, 0, this.holdingItem)
}
this.doll.kill();
this.isSpawned = false;
NotificationCenter.trigger("player/killed", this);
};
@ -90,6 +103,9 @@ function (Doll, Settings, NotificationCenter) {
}
Player.prototype.destroy = function () {
if(this.holdingItem) {
this.throw(0, 0, this.holdingItem);
}
this.doll.destroy();
}