From cc2563f8f64e8448cac7e60e9b32189499b4d080 Mon Sep 17 00:00:00 2001 From: Jeremiah Billmann Date: Tue, 9 Jul 2013 19:28:40 -0400 Subject: [PATCH] Major refactor for #17 - prompted by #3 --- example/game.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 example/game.js diff --git a/example/game.js b/example/game.js new file mode 100644 index 0000000..7b884d3 --- /dev/null +++ b/example/game.js @@ -0,0 +1,29 @@ +var garageServer = require('../lib/server/garageserver.io'), + gamePhysics = require('./shared/core'); + +exports = module.exports = Game; + +function Game (sockets) { + this.physicsInterval = 15; + this.physicsDelta = this.physicsInterval / 1000; + this.physicsIntervalId = 0; + + this.server = garageServer.createGarageServer(sockets, + { + logging: true, + interpolation: true, + clientSidePrediction: true, + onUpdatePlayerPhysics: gamePhysics.onUpdatePlayerPhysics, + onUpdateEntityPhysics: gamePhysics.onUpdateEntityPhysics + }); +} + +Game.prototype.start = function () { + var self = this; + this.server.start(); + this.physicsIntervalId = setInterval(function () { self.update(); }, this.physicsInterval); +}; + +Game.prototype.update = function () { + +}; \ No newline at end of file