mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-12 02:57:34 +00:00
ground work for different users on server and players on client
This commit is contained in:
parent
e37d1eeb2e
commit
2cb401bbd3
9 changed files with 122 additions and 54 deletions
|
|
@ -1,6 +1,7 @@
|
|||
define(["Vendor/Box2D", "Chuck/Settings"], function(Box2D, Settings){
|
||||
|
||||
function Doll (physicsEngine){
|
||||
function Doll (physicsEngine, id){
|
||||
this.id = id;
|
||||
this._physicsEngine = physicsEngine;
|
||||
this._body;
|
||||
this._legs;
|
||||
|
|
@ -30,14 +31,14 @@ define(["Vendor/Box2D", "Chuck/Settings"], function(Box2D, Settings){
|
|||
headShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, -37 / Settings.RATIO));
|
||||
fixtureDef.shape = headShape;
|
||||
fixtureDef.isSensor = false;
|
||||
fixtureDef.userData = 'myHead';
|
||||
fixtureDef.userData = 'myHead' + this.id;
|
||||
this._body.CreateFixture(fixtureDef);
|
||||
|
||||
var bodyShape = new Box2D.Collision.Shapes.b2PolygonShape();
|
||||
bodyShape.SetAsOrientedBox(5 / Settings.RATIO, 16 / Settings.RATIO, new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, -21 / Settings.RATIO));
|
||||
fixtureDef.shape = bodyShape;
|
||||
fixtureDef.isSensor = false;
|
||||
fixtureDef.userData = 'myBody';
|
||||
fixtureDef.userData = 'myBody' + this.id;
|
||||
this._body.CreateFixture(fixtureDef);
|
||||
|
||||
var legsShape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
|
|
@ -46,7 +47,7 @@ define(["Vendor/Box2D", "Chuck/Settings"], function(Box2D, Settings){
|
|||
fixtureDef.shape = legsShape;
|
||||
fixtureDef.friction = Settings.PLAYER_FRICTION;
|
||||
fixtureDef.isSensor = false;
|
||||
fixtureDef.userData = 'myLegs';
|
||||
fixtureDef.userData = 'myLegs' + this.id;
|
||||
this._legs = this._body.CreateFixture(fixtureDef);
|
||||
|
||||
var feetShape = new Box2D.Collision.Shapes.b2CircleShape();
|
||||
|
|
@ -54,7 +55,7 @@ define(["Vendor/Box2D", "Chuck/Settings"], function(Box2D, Settings){
|
|||
feetShape.SetLocalPosition(new Box2D.Common.Math.b2Vec2(0 / Settings.RATIO, 0 / Settings.RATIO));
|
||||
fixtureDef.shape = feetShape;
|
||||
fixtureDef.isSensor = true;
|
||||
fixtureDef.userData = 'myFeet';
|
||||
fixtureDef.userData = 'myFeet' + this.id;
|
||||
this._body.CreateFixture(fixtureDef);
|
||||
|
||||
this._body.SetActive(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue