This commit is contained in:
logsol 2014-02-24 10:39:41 +01:00
commit f578b92734
4 changed files with 26 additions and 6 deletions

View file

@ -66,7 +66,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
if(updateData[gameObject.uid]) {
var update = updateData[gameObject.uid];
body.SetAwake(true);
body.SetPosition(update.p);
body.SetPosition(this.centerBetween(update.p, body.GetPosition()));
body.SetAngle(update.a);
body.SetLinearVelocity(update.lv);
body.SetAngularVelocity(update.av);
@ -82,6 +82,24 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
}
GameController.prototype.centerBetween = function(n, o) {
var x, y;
if(n.x > o.x) {
x = o.x + (n.x - o.x) / 2;
} else {
x = o.x - (o.x - n.x) / 2;
}
if(n.y > o.y) {
y = o.y + (n.y - o.y) / 2;
} else {
y = o.y - (o.y - n.y) / 2;
}
return {x:x, y:y};
};
GameController.prototype.onJoinMe = function (playerId) {
this.me = this.players[playerId];
this.me.setPlayerController(new PlayerController(this.me));

View file

@ -230,7 +230,9 @@ function (Parent, DomController, PIXI, Settings, NotificationCenter) {
playerInfo.endFill();
if(options.healthFactor > 0) {
playerInfo.beginFill(0x00FF00);
var color = 0x00FF00;
if(options.healthFactor < 0.30) color = 0xFF0000;
playerInfo.beginFill(color);
playerInfo.lineStyle(0, 0x000000);
playerInfo.drawRect(borderWidth, borderWidth, width * options.healthFactor, height);
playerInfo.endFill();

View file

@ -33,7 +33,7 @@ define(function() {
FLY_SPEED: 6.2,
JUMP_SPEED: 20,
JUMP_STOP_DAMPING_FACTOR: 0.5,
MAX_THROW_FORCE: 18,
MAX_THROW_FORCE: 18 * 3.5,
MAX_THROW_ANGULAR_VELOCITY: 0,
MAX_RUNNING_WEIGHT: 9,
RESPAWN_TIME: 6,

View file

@ -121,8 +121,8 @@ function (Parent, Box2D, Options, Settings) {
body.SetAwake(true);
var vector = new Box2D.Common.Math.b2Vec2(
x * Settings.MAX_THROW_FORCE,
-y * Settings.MAX_THROW_FORCE * 1.5 // 1.5 is to throw higher then far
x * Settings.MAX_THROW_FORCE / this.options.weight,
-y * Settings.MAX_THROW_FORCE * 1.5 / this.options.weight // 1.5 is to throw higher then far
);
this.body.SetLinearVelocity(vector);