mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added washing machine, fixed grabbing and rotation and position
This commit is contained in:
parent
3a07d946b0
commit
fa9a0d5d22
5 changed files with 55 additions and 13 deletions
|
|
@ -48,6 +48,21 @@ function (Parent, Settings, NotificationCenter) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item.prototype.flip = function(direction) {
|
||||||
|
var oldFlipDirection = this.flipDirection;
|
||||||
|
|
||||||
|
Parent.prototype.flip.call(this, direction);
|
||||||
|
|
||||||
|
if(oldFlipDirection != direction) {
|
||||||
|
NotificationCenter.trigger("view/updateMesh",
|
||||||
|
this.mesh,
|
||||||
|
{
|
||||||
|
xScale: direction
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return Item;
|
return Item;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -23,10 +23,10 @@ define({
|
||||||
|
|
||||||
// GAME PLAY
|
// GAME PLAY
|
||||||
WALK_SPEED: 4,
|
WALK_SPEED: 4,
|
||||||
RUN_SPEED: 6.4,
|
RUN_SPEED: 8,
|
||||||
FLY_SPEED: 5.12,
|
FLY_SPEED: 6.2,
|
||||||
JUMP_SPEED: 70,
|
JUMP_SPEED: 70,
|
||||||
MAX_THROW_FORCE: 15,
|
MAX_THROW_FORCE: 18,
|
||||||
|
|
||||||
// restitution: bouncyness, friction: rubbing, density: mass
|
// restitution: bouncyness, friction: rubbing, density: mass
|
||||||
TILE_FRICTION: 0.99,
|
TILE_FRICTION: 0.99,
|
||||||
|
|
|
||||||
|
|
@ -250,10 +250,11 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
|
||||||
var p = this.body.GetPosition();
|
var p = this.body.GetPosition();
|
||||||
this.holdingItem.body.SetPosition(new Box2D.Common.Math.b2Vec2(
|
this.holdingItem.body.SetPosition(new Box2D.Common.Math.b2Vec2(
|
||||||
p.x + ((this.holdingItem.options.width / Settings.RATIO / 2 + 5 / Settings.RATIO) * this.lookDirection),
|
p.x + ((this.holdingItem.options.width / Settings.RATIO / 2 + 5 / Settings.RATIO) * this.lookDirection),
|
||||||
p.y - (this.holdingItem.options.height / Settings.RATIO / 2)
|
p.y - 1
|
||||||
));
|
));
|
||||||
|
this.holdingItem.flip(this.lookDirection);
|
||||||
//this.holdingItem.body.SetAngle(Math.PI * 2 / 180 * 20 * -this.lookDirection);
|
//this.holdingItem.body.SetAngle(Math.PI * 2 / 180 * 20 * -this.lookDirection);
|
||||||
this.holdingItem.body.SetAngle(0);
|
this.holdingItem.body.SetAngle((this.holdingItem.options.grabAngle || 0) * this.lookDirection);
|
||||||
|
|
||||||
var jointDef = new Box2D.Dynamics.Joints.b2WeldJointDef();
|
var jointDef = new Box2D.Dynamics.Joints.b2WeldJointDef();
|
||||||
jointDef.Initialize(this.body, this.holdingItem.body, this.holdingItem.body.GetWorldCenter());
|
jointDef.Initialize(this.body, this.holdingItem.body, this.holdingItem.body.GetWorldCenter());
|
||||||
|
|
@ -273,11 +274,11 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
|
||||||
body.ApplyImpulse(
|
body.ApplyImpulse(
|
||||||
new Box2D.Common.Math.b2Vec2(
|
new Box2D.Common.Math.b2Vec2(
|
||||||
x * Settings.MAX_THROW_FORCE,
|
x * Settings.MAX_THROW_FORCE,
|
||||||
-y * Settings.MAX_THROW_FORCE * 2 // 2 is to throw higher then far
|
-y * Settings.MAX_THROW_FORCE * 1.5 // 1.5 is to throw higher then far
|
||||||
),
|
),
|
||||||
body.GetLocalCenter()
|
body.GetLocalCenter()
|
||||||
);
|
);
|
||||||
body.SetAngularVelocity(5);
|
body.SetAngularVelocity(8 * x);
|
||||||
};
|
};
|
||||||
|
|
||||||
Doll.prototype.onFootSensorDetection = function(isColliding, fixture) {
|
Doll.prototype.onFootSensorDetection = function(isColliding, fixture) {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ function (Parent, Box2D, Settings) {
|
||||||
Parent.call(this, physicsEngine, uid);
|
Parent.call(this, physicsEngine, uid);
|
||||||
this.createFixture();
|
this.createFixture();
|
||||||
this.body.ResetMassData();
|
this.body.ResetMassData();
|
||||||
|
this.flipDirection = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item.prototype = Object.create(Parent.prototype);
|
Item.prototype = Object.create(Parent.prototype);
|
||||||
|
|
@ -47,6 +48,12 @@ function (Parent, Box2D, Settings) {
|
||||||
this.body.CreateFixture(fixtureDef);
|
this.body.CreateFixture(fixtureDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item.prototype.flip = function(direction) {
|
||||||
|
this.flipDirection = direction;
|
||||||
|
|
||||||
|
// FIXME: implement body flip if necessary
|
||||||
|
};
|
||||||
|
|
||||||
return Item;
|
return Item;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -125,7 +125,8 @@ microwave: 3.744
|
||||||
depth: 3,
|
depth: 3,
|
||||||
x:40,
|
x:40,
|
||||||
y:0,
|
y:0,
|
||||||
rotation: 0
|
rotation: 0,
|
||||||
|
grabAngle: 0.5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:'Refridgerator',
|
name:'Refridgerator',
|
||||||
|
|
@ -137,7 +138,8 @@ microwave: 3.744
|
||||||
height:53,
|
height:53,
|
||||||
x:120,
|
x:120,
|
||||||
y:0,
|
y:0,
|
||||||
rotation: 0
|
rotation: 0,
|
||||||
|
grabAngle: -0.5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:'Microwave',
|
name:'Microwave',
|
||||||
|
|
@ -150,7 +152,8 @@ microwave: 3.744
|
||||||
depth: 12,
|
depth: 12,
|
||||||
x:100,
|
x:100,
|
||||||
y:0,
|
y:0,
|
||||||
rotation: 0
|
rotation: 0,
|
||||||
|
grabAngle: -0.1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:'Large Cleaver',
|
name:'Large Cleaver',
|
||||||
|
|
@ -162,7 +165,8 @@ microwave: 3.744
|
||||||
height:22,
|
height:22,
|
||||||
x:40,
|
x:40,
|
||||||
y:0,
|
y:0,
|
||||||
rotation: 0
|
rotation: 0,
|
||||||
|
grabAngle: 0.3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:'Small Cleaver',
|
name:'Small Cleaver',
|
||||||
|
|
@ -174,7 +178,8 @@ microwave: 3.744
|
||||||
height:17,
|
height:17,
|
||||||
x:60,
|
x:60,
|
||||||
y:0,
|
y:0,
|
||||||
rotation: 0
|
rotation: 0,
|
||||||
|
grabAngle: 0.3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:'Coffeemachine',
|
name:'Coffeemachine',
|
||||||
|
|
@ -198,7 +203,21 @@ microwave: 3.744
|
||||||
height:15,
|
height:15,
|
||||||
x:140,
|
x:140,
|
||||||
y:0,
|
y:0,
|
||||||
rotation: 0
|
rotation: 0,
|
||||||
|
grabAngle: 0.3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:'Laundry Machine',
|
||||||
|
image:'laundry_machine.gif',
|
||||||
|
shape:'rectangle',
|
||||||
|
category:'laundry',
|
||||||
|
weight: 15,
|
||||||
|
width:24,
|
||||||
|
height:31,
|
||||||
|
x:600,
|
||||||
|
y:0,
|
||||||
|
rotation: 0,
|
||||||
|
grabAngle: -0.5
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
tiles: /*
|
tiles: /*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue