mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Implemented local positioning as master - included punkbuster instead of webrtc for now. #49
This commit is contained in:
parent
efe4c76cc2
commit
e7f4b6043d
7 changed files with 124 additions and 24 deletions
|
|
@ -1,10 +1,11 @@
|
|||
define([
|
||||
"Game/Core/Control/PlayerController",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Lib/Utilities/Protocol/Parser"
|
||||
"Lib/Utilities/Protocol/Parser",
|
||||
"Game/Config/Settings"
|
||||
],
|
||||
|
||||
function(Parent, Nc, Parser) {
|
||||
function(Parent, Nc, Parser, Settings) {
|
||||
|
||||
function PlayerController(player) {
|
||||
|
||||
|
|
@ -39,6 +40,27 @@ function(Parent, Nc, Parser) {
|
|||
this.player.suicide();
|
||||
};
|
||||
|
||||
PlayerController.prototype.meStateUpdate = function(update) {
|
||||
|
||||
if(!this.player.doll) {
|
||||
console.warn('me state update, even though doll does not exist');
|
||||
return;
|
||||
}
|
||||
|
||||
var difference = {
|
||||
x: Math.abs(update.p.x - this.player.doll.body.GetPosition().x),
|
||||
y: Math.abs(update.p.y - this.player.doll.body.GetPosition().y)
|
||||
}
|
||||
|
||||
if(difference.x < Settings.PUNKBUSTER_DIFFERENCE_METERS
|
||||
|| difference.y < Settings.PUNKBUSTER_DIFFERENCE_METERS) {
|
||||
this.player.doll.body.SetAwake(true);
|
||||
this.player.doll.body.SetPosition(update.p);
|
||||
} else {
|
||||
// HARD UPDATE FOR SELF
|
||||
}
|
||||
};
|
||||
|
||||
return PlayerController;
|
||||
|
||||
});
|
||||
|
|
@ -108,7 +108,7 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
|
|||
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, 'worldUpdate', update);
|
||||
}
|
||||
|
||||
this.worldUpdateTimeout = setTimeout(this.updateWorld.bind(this), Settings.WORLD_UPDATE_BROADCAST_INTERVAL);
|
||||
this.worldUpdateTimeout = setTimeout(this.updateWorld.bind(this), Settings.NETWORK_UPDATE_INTERVAL);
|
||||
}
|
||||
|
||||
GameController.prototype.getWorldUpdateObject = function(getSleeping) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue