refactored grabbing

This commit is contained in:
Jeena 2014-01-20 18:15:40 +01:00
parent 1c4336c7f7
commit 38b5023410
7 changed files with 124 additions and 62 deletions

View file

@ -52,23 +52,16 @@ function (Doll, Settings) {
if(this.doll) this.doll.lookAt(x, y);
}
Player.prototype.handAction = function(x, y, isHolding, item) {
if (isHolding) {
// throw
if(item.isReleasingAllowed()) {
item.beingReleased(this);
this.doll.throw(item, x, y);
this.holdingItem = null;
}
} else {
// take
if(item.isGrabbingAllowed()) {
item.beingGrabbed(this);
this.doll.grab(item);
this.holdingItem = item;
}
}
Player.prototype.grab = function(item) {
item.beingGrabbed(this);
this.doll.grab(item);
this.holdingItem = item;
};
Player.prototype.throw = function(x, y, item) {
item.beingReleased(this);
this.doll.throw(item, x, y);
this.holdingItem = null;
};
Player.prototype.update = function () {