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
|
|
@ -158,16 +158,8 @@ 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 {
|
||||
x: pos.x,
|
||||
y: pos.y
|
||||
};
|
||||
return this.body.GetPosition().Copy();
|
||||
};
|
||||
|
||||
Doll.prototype.getHeadPosition = function() {
|
||||
|
|
@ -235,7 +227,13 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
|
|||
Doll.prototype.stop = function () {
|
||||
this.moveDirection = 0;
|
||||
this.setFriction(Settings.PLAYER_FRICTION);
|
||||
if(this.isStanding()) this.setActionState("stand");
|
||||
if(this.isStanding()) {
|
||||
this.setActionState("stand");
|
||||
} else {
|
||||
var vector = this.body.GetLinearVelocity().Copy();
|
||||
vector.x *= Settings.JUMP_STOP_DAMPING_FACTOR;
|
||||
this.body.SetLinearVelocity(vector);
|
||||
}
|
||||
}
|
||||
|
||||
Doll.prototype.jump = function () {
|
||||
|
|
@ -251,6 +249,17 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
|
|||
}
|
||||
}
|
||||
|
||||
Doll.prototype.jumpStop = function () {
|
||||
if (!this.isStanding() ) {
|
||||
this.body.SetAwake(true);
|
||||
var vector = this.body.GetLinearVelocity().Copy();
|
||||
if(vector.y < 0) {
|
||||
vector.y *= Settings.JUMP_STOP_DAMPING_FACTOR;
|
||||
this.body.SetLinearVelocity(vector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Doll.prototype.setStanding = function (isStanding) {
|
||||
if (this.standing == isStanding) return;
|
||||
this.standing = isStanding;
|
||||
|
|
@ -344,6 +353,13 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
|
|||
}
|
||||
}
|
||||
|
||||
Doll.prototype.getVelocities = function() {
|
||||
return {
|
||||
linearVelocity: this.body.GetLinearVelocity(),
|
||||
angularVelocity: this.body.GetAngularVelocity()
|
||||
};
|
||||
};
|
||||
|
||||
Doll.prototype.update = function() {
|
||||
|
||||
if (this.body.GetLinearVelocity().x == 0 && this.isWalking()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue