From 2e714b80ce26e24e8f0736cf8bf49d45e6722c46 Mon Sep 17 00:00:00 2001 From: Jeremiah Billmann Date: Sun, 14 Jul 2013 10:57:18 -0400 Subject: [PATCH] Used world state for heigh/width --- client/garageserver.io.js | 6 +++--- example/game.js | 3 ++- example/public/javascripts/game.js | 6 +++++- example/public/stylesheets/style.css | 1 - 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/client/garageserver.io.js b/client/garageserver.io.js index 21c7f37..51abeba 100644 --- a/client/garageserver.io.js +++ b/client/garageserver.io.js @@ -6,7 +6,7 @@ options = { onPlayerUpdate: function (state), onEntityUpdate: function (state), onPlayerRemove: function (id), - onGameState: function (state), + onWorldState: function (state), onPing: function (pingDelay), onUpdatePlayerPhysics: function (state, inputs, deltaTime), onInterpolation: function(previousState, targetState, amount) @@ -175,8 +175,8 @@ var GarageServerIO = (function (socketio) { } }); _socket.on('state', function (data) { - if (_options.onGameState) { - _options.onGameState(data); + if (_options.onWorldState) { + _options.onWorldState(data.worldState); } _stateController.physicsDelta = data.physicsDelta; _stateController.interpolation = data.interpolation; diff --git a/example/game.js b/example/game.js index 76bff2e..becada5 100644 --- a/example/game.js +++ b/example/game.js @@ -13,7 +13,8 @@ function Game (sockets) { logging: true, interpolation: true, clientSidePrediction: true, - smoothingFactor: this.physicsDelta * 20 + smoothingFactor: this.physicsDelta * 20, + worldState: { height: '400px', width: '800px' } }); } diff --git a/example/public/javascripts/game.js b/example/public/javascripts/game.js index 3a15dfa..4f1c253 100644 --- a/example/public/javascripts/game.js +++ b/example/public/javascripts/game.js @@ -7,7 +7,11 @@ $(function () { GarageServerIO.initializeGarageServer('http://garageserver_io.jbillmann.c9.io', { logging: true, onUpdatePlayerPhysics: GamePhysics.getNewState, - onInterpolation: GamePhysics.getInterpolatedState + onInterpolation: GamePhysics.getInterpolatedState, + onWorldState: function (state) { + document.getElementById('gameCanvas').style.width = state.width; + document.getElementById('gameCanvas').style.height = state.height; + } }); GarageServerIO.setState({ x: 0, y: 0 }); diff --git a/example/public/stylesheets/style.css b/example/public/stylesheets/style.css index f8ff6c8..ec7f7ac 100644 --- a/example/public/stylesheets/style.css +++ b/example/public/stylesheets/style.css @@ -5,7 +5,6 @@ margin-left: auto; margin-right: auto; display: block; - width: 800px; } #fps {