mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Merge branch 'master' of https://github.com/logsol/chuck.js
This commit is contained in:
commit
f578b92734
4 changed files with 26 additions and 6 deletions
|
|
@ -65,8 +65,8 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
|||
var gameObject = userData;
|
||||
if(updateData[gameObject.uid]) {
|
||||
var update = updateData[gameObject.uid];
|
||||
body.SetAwake(true);
|
||||
body.SetPosition(update.p);
|
||||
body.SetAwake(true);
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue