From c06b54e6628e9c6850b36f3e3b16ac58dc8bfe85 Mon Sep 17 00:00:00 2001 From: Jeremiah Billmann Date: Tue, 23 Jul 2013 17:58:09 -0400 Subject: [PATCH] Updating documentation - ways to go --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 496d9b9..9411c29 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,34 @@ A simple, lightweight, HTML multiplayer game server (and client) for Node.js ### Server +```js +var garageServer = require('.garageserver.io'), + +// Create instance of GarageServer.IO - pass in Socket.IO and GarageServer.IO options +var server = garageServer.createGarageServer(sockets, + { + interpolation: true, + clientSidePrediction: true, + worldState: { width: '400px', height: '400px'; } + }); + +// Start GarageServer.IO instance prior to starting physics loop +server.start(); + +// Inside physics loop, process inputs for players, process entites and update state + var players = server.getPlayers(), + entities = server.getEntities(), + +players.forEach(function (player) { + // Calculate new state from player.state and player.inputs + server.updatePlayerState(player.id, newState); +}); +entities.forEach(function (entity) { + // Calculate new state from entity.state + server.updateEntityState(entity.id, newState); +}); +``` + ### Client ```js