added angular throwing

This commit is contained in:
logsol 2014-12-25 00:33:00 +01:00
parent 9100215ceb
commit d24ab60756
12 changed files with 93 additions and 34 deletions

View file

@ -354,12 +354,12 @@ function (Parent, Box2D, Settings, CollisionDetector, Item, Nc) {
}
};
Doll.prototype.throw = function(item, x, y) {
Doll.prototype.throw = function(item, options) {
this.body.GetWorld().DestroyJoint(this.holdingJoint);
this.holdingJoint = null;
this.holdingItem = null;
item.throw(x, y);
item.throw(options);
};
Doll.prototype.isAnotherPlayerNearby = function() {

View file

@ -129,17 +129,17 @@ function (Parent, Box2D, Options, Settings, Exception, Nc) {
return this.body.GetWorldCenter();
};
Item.prototype.throw = function(x, y) {
Item.prototype.throw = function(options) {
var body = this.body;
body.SetAwake(true);
var vector = new Box2D.Common.Math.b2Vec2(
x * Settings.MAX_THROW_FORCE / this.options.weight,
-y * Settings.MAX_THROW_FORCE / this.options.weight
options.x * Settings.MAX_THROW_FORCE / this.options.weight,
-options.y * Settings.MAX_THROW_FORCE / this.options.weight
);
this.body.SetLinearVelocity(vector);
body.SetAngularVelocity(Settings.MAX_THROW_ANGULAR_VELOCITY * x);
body.SetAngularVelocity(-options.av * Settings.MAX_THROW_ANGULAR_VELOCITY);
};
Item.prototype.destroy = function() {