mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixes #78 revisited weight handycap
This commit is contained in:
parent
b6d67a0581
commit
e404ad3598
7 changed files with 27 additions and 16 deletions
|
|
@ -59,10 +59,13 @@ function (Parent, Item, Box2D, Nc) {
|
||||||
if(item.lastMoved && item.lastMoved.player != this.player) {
|
if(item.lastMoved && item.lastMoved.player != this.player) {
|
||||||
var damageVector = b2Math.SubtractVV(itemVelocity, ownVelocity);
|
var damageVector = b2Math.SubtractVV(itemVelocity, ownVelocity);
|
||||||
damageVector.Abs();
|
damageVector.Abs();
|
||||||
damageVector.Multiply(0.7);
|
var velocity = damageVector.Length();
|
||||||
damageVector.Multiply(itemMass * 1.3);
|
damageVector.Multiply(itemMass / 3.6);
|
||||||
var damage = damageVector.Length();
|
var damage = damageVector.Length();
|
||||||
damage *= item.options.danger ? item.options.danger : 1;
|
|
||||||
|
if(item.options.danger) {
|
||||||
|
damage += item.options.danger * 90 * (velocity / 128) * (itemMass + 1);
|
||||||
|
}
|
||||||
|
|
||||||
var player = item.lastMoved.player;
|
var player = item.lastMoved.player;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,11 @@ function (Parent, KeyboardInput, DomController, Settings, Swiper) {
|
||||||
self.playerController.handActionRequest(options);
|
self.playerController.handActionRequest(options);
|
||||||
} else {
|
} else {
|
||||||
self.swiper = new Swiper();
|
self.swiper = new Swiper();
|
||||||
self.swiper.draw(e);
|
|
||||||
|
self.draw({
|
||||||
|
movementX: 0,
|
||||||
|
movementY: 0
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,6 +188,7 @@ function (Parent, KeyboardInput, DomController, Settings, Swiper) {
|
||||||
|
|
||||||
this.mousePosition.x += movementX;
|
this.mousePosition.x += movementX;
|
||||||
this.mousePosition.y += movementY;
|
this.mousePosition.y += movementY;
|
||||||
|
|
||||||
this.swiper.swipe(this.mousePosition.x, -this.mousePosition.y);
|
this.swiper.swipe(this.mousePosition.x, -this.mousePosition.y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ define(function() {
|
||||||
|
|
||||||
var ItemSettings = {
|
var ItemSettings = {
|
||||||
|
|
||||||
|
// weight is a number between 0.1 for very light and 10 for very heavy
|
||||||
|
|
||||||
"Default":
|
"Default":
|
||||||
{
|
{
|
||||||
"category": "",
|
"category": "",
|
||||||
|
|
@ -15,7 +17,7 @@ define(function() {
|
||||||
"rotation": "0",
|
"rotation": "0",
|
||||||
"bounce": "0",
|
"bounce": "0",
|
||||||
"grabAngle": "-1.5",
|
"grabAngle": "-1.5",
|
||||||
"danger": "1",
|
"danger": "0",
|
||||||
"bodyType": "dynamic",
|
"bodyType": "dynamic",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -25,7 +27,7 @@ define(function() {
|
||||||
"image": "chest.png",
|
"image": "chest.png",
|
||||||
|
|
||||||
"type": "ragdoll",
|
"type": "ragdoll",
|
||||||
"weight": "5",
|
"weight": "7",
|
||||||
"width": "6",
|
"width": "6",
|
||||||
"height": "12",
|
"height": "12",
|
||||||
|
|
||||||
|
|
@ -200,7 +202,7 @@ define(function() {
|
||||||
"category": "kitchen",
|
"category": "kitchen",
|
||||||
"image": "fridge.gif",
|
"image": "fridge.gif",
|
||||||
|
|
||||||
"weight": "10",
|
"weight": "5",
|
||||||
"width": "31",
|
"width": "31",
|
||||||
"height": "53",
|
"height": "53",
|
||||||
|
|
||||||
|
|
@ -213,11 +215,12 @@ define(function() {
|
||||||
"category": "kitchen",
|
"category": "kitchen",
|
||||||
"image": "microwave.gif",
|
"image": "microwave.gif",
|
||||||
|
|
||||||
"weight": "3.6",
|
"weight": "4.6",
|
||||||
"width": "19",
|
"width": "19",
|
||||||
"height": "12",
|
"height": "12",
|
||||||
|
|
||||||
"grabAngle": "-0.1",
|
"grabAngle": "-0.1",
|
||||||
|
"danger": "2",
|
||||||
},
|
},
|
||||||
|
|
||||||
"Coffeemachine":
|
"Coffeemachine":
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ define(function() {
|
||||||
WALK_SPEED: 4,
|
WALK_SPEED: 4,
|
||||||
RUN_SPEED: 8,
|
RUN_SPEED: 8,
|
||||||
FLY_SPEED: 6.2,
|
FLY_SPEED: 6.2,
|
||||||
JUMP_SPEED: 21,
|
JUMP_SPEED: 19,
|
||||||
JUMP_STOP_DAMPING_FACTOR: 0.5,
|
JUMP_STOP_DAMPING_FACTOR: 0.5,
|
||||||
MAX_THROW_FORCE: 28,
|
MAX_THROW_FORCE: 28,
|
||||||
MAX_THROW_ANGULAR_VELOCITY: 3,
|
MAX_THROW_ANGULAR_VELOCITY: 3,
|
||||||
|
|
@ -51,7 +51,7 @@ define(function() {
|
||||||
TILE_FRICTION: 0.99,
|
TILE_FRICTION: 0.99,
|
||||||
TILE_RESTITUTION: 0.1,
|
TILE_RESTITUTION: 0.1,
|
||||||
|
|
||||||
PLAYER_DENSITY: 3.68,
|
PLAYER_DENSITY: 12.2, //3.68,
|
||||||
PLAYER_FRICTION: 5,
|
PLAYER_FRICTION: 5,
|
||||||
PLAYER_MOTION_FRICTION: 0.1,
|
PLAYER_MOTION_FRICTION: 0.1,
|
||||||
PLAYER_RESTITUTION: 0.0,
|
PLAYER_RESTITUTION: 0.0,
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,10 @@ function (Parent, Box2D, Settings, CollisionDetector, Item, Nc) {
|
||||||
if (this.isStanding()) {
|
if (this.isStanding()) {
|
||||||
|
|
||||||
this.body.SetAwake(true);
|
this.body.SetAwake(true);
|
||||||
var vector = new Box2D.Common.Math.b2Vec2(0, -Settings.JUMP_SPEED);
|
|
||||||
|
var jumpSpeed = Settings.JUMP_SPEED;
|
||||||
|
|
||||||
|
var vector = new Box2D.Common.Math.b2Vec2(0, -jumpSpeed);
|
||||||
this.body.SetLinearVelocity(vector);
|
this.body.SetLinearVelocity(vector);
|
||||||
|
|
||||||
this.setStanding(false);
|
this.setStanding(false);
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,7 @@ function (Parent, Box2D, Options, Settings, Exception, Nc) {
|
||||||
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
var fixtureDef = new Box2D.Dynamics.b2FixtureDef();
|
||||||
fixtureDef.shape = itemShape;
|
fixtureDef.shape = itemShape;
|
||||||
|
|
||||||
var offset = 4,
|
fixtureDef.density = this.options.weight;
|
||||||
factor = 80;
|
|
||||||
var density = ((this.options.weight + offset) / this.options.width / this.options.height) * factor;
|
|
||||||
fixtureDef.density = density;
|
|
||||||
fixtureDef.friction = Settings.ITEM_FRICTION;
|
fixtureDef.friction = Settings.ITEM_FRICTION;
|
||||||
|
|
||||||
fixtureDef.restitution = this.options.bounce
|
fixtureDef.restitution = this.options.bounce
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ function (Nc, ProtocolHelper, validate, Options, Settings, FileSystem) {
|
||||||
maps.push(fileinfo[0]);
|
maps.push(fileinfo[0]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return maps.sort();
|
return ["stones"];//maps.sort();
|
||||||
};
|
};
|
||||||
|
|
||||||
return Api;
|
return Api;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue