From b6981f21fad588748af6de0a2bfe2f9c127c9855 Mon Sep 17 00:00:00 2001 From: Jeremiah Billmann Date: Sat, 8 Jun 2013 11:54:54 -0400 Subject: [PATCH] Progress: Physics --- client/garageserver.io.js | 11 ++++++++++- example/public/javascripts/game.js | 16 +++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/client/garageserver.io.js b/client/garageserver.io.js index a85442a..f4a0f56 100644 --- a/client/garageserver.io.js +++ b/client/garageserver.io.js @@ -109,6 +109,14 @@ window.GarageServerIO = (function (window, socketio) { var currentTime = new Date().getTime(); socket.emit('input', { input: input, seq: sequenceNumber, timestamp: currentTime }); }, + + processPlayerInput = function () { + for (var i = 0; i < players.length; i ++) { + if (players[i].id !== socket.socket.sessionid) { + + } + } + }, removePlayer = function (id, options) { for (var i = 0; i < players.length; i ++) { @@ -125,7 +133,8 @@ window.GarageServerIO = (function (window, socketio) { return { connectToGarageServer: connectToGarageServer, - addPlayerInput: addPlayerInput + addPlayerInput: addPlayerInput, + processPlayerInput: processPlayerInput }; }) (window, io); \ No newline at end of file diff --git a/example/public/javascripts/game.js b/example/public/javascripts/game.js index 0d46094..f2fe3db 100644 --- a/example/public/javascripts/game.js +++ b/example/public/javascripts/game.js @@ -13,24 +13,30 @@ $(function () { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) { window.setTimeout(callback, 1000/60); }; })(), - handleInput = function (){ - if(keyboard.pressed('left')) { + handleInput = function () { + if (keyboard.pressed('left')) { x -= 1; GarageServerIO.addPlayerInput('left'); } - if(keyboard.pressed('right')) { + if (keyboard.pressed('right')) { x += 1; GarageServerIO.addPlayerInput('right'); } - if(keyboard.pressed('down')) { + if (keyboard.pressed('down')) { y += 1; GarageServerIO.addPlayerInput('down'); } - if(keyboard.pressed('up')) { + if (keyboard.pressed('up')) { y -= 1; GarageServerIO.addPlayerInput('up'); } }, + + processInputs = function () { + //GarageServerIO.processPlayerInput + + + }, update = function () { requestAnimFrame(update);