diff --git a/lib/Chuck/ClientGame.js b/lib/Chuck/ClientGame.js new file mode 100644 index 0000000..ec6a3a9 --- /dev/null +++ b/lib/Chuck/ClientGame.js @@ -0,0 +1,21 @@ +define(["Chuck/Processors/ClientProcessor"], function(ClientProcessor) { + + function ClientGame(networker){ + this.networker = networker; + this.processor = new ClientProcessor(); + } + + ClientGame.prototype.loadLevel = function(path) { + this.processor.loadLevel(path); + } + + ClientGame.prototype.processGameCommand = function(command, options){ + console.log('(not implemented) processGameCommand:', command, options); + } + + ClientGame.prototype.destruct = function(){ + this.processor.destruct(); + } + + return ClientGame; +}); \ No newline at end of file diff --git a/lib/Chuck/Processors/ClientProcessor.js b/lib/Chuck/Processors/ClientProcessor.js index bbef4e3..047f4de 100755 --- a/lib/Chuck/Processors/ClientProcessor.js +++ b/lib/Chuck/Processors/ClientProcessor.js @@ -9,7 +9,8 @@ var requires = [ "RequestAnimationFrame" ]; -define(requires, function(ViewController, PhysicsEngine, Player, InputControlUnit, Settings, Box2D, Level, requestAnimFrame){ +define(requires, + function(ViewController, PhysicsEngine, Player, InputControlUnit, Settings, Box2D, Level, requestAnimFrame) { function ClientGame () { this.init(); diff --git a/lib/Chuck/ServerGame.js b/lib/Chuck/ServerGame.js new file mode 100644 index 0000000..bccdf90 --- /dev/null +++ b/lib/Chuck/ServerGame.js @@ -0,0 +1,21 @@ +define(["Chuck/Processors/ServerProcessor"], function(ServerProcessor) { + + function ServerGame(chanel) { + this.chanel = chanel; + this.processor = new ServerProcessor(); + } + + ServerGame.prototype.loadLevel = function(path) { + this.processor.loadLevel(path); + } + + ServerGame.prototype.processGameCommand = function(command, options) { + console.log('(not implemented) processGameCommand:', command, options); + } + + ServerGame.prototype.destruct = function() { + this.processor.destruct(); + } + + return ServerGame; +}); \ No newline at end of file diff --git a/lib/Client/Networker.js b/lib/Client/Networker.js index 9d76125..c3fbfd8 100644 --- a/lib/Client/Networker.js +++ b/lib/Client/Networker.js @@ -1,8 +1,8 @@ -define(["Protocol/Helper", "Chuck/Game"], function(ProtocolHelper, Game) { +define(["Protocol/Helper", "Chuck/ClientGame"], function(ProtocolHelper, ClientGame) { function Networker(socketLink) { this.socketLink = socketLink; - this.game = null; + this.clientGame = null; this.init(); } @@ -36,8 +36,8 @@ define(["Protocol/Helper", "Chuck/Game"], function(ProtocolHelper, Game) { } Networker.prototype.onDisconnect = function() { - this.game.destruct(); - this.game = null; + this.clientGame.destruct(); + this.clientGame = null; } Networker.prototype.join = function(channelName){ @@ -50,7 +50,8 @@ define(["Protocol/Helper", "Chuck/Game"], function(ProtocolHelper, Game) { } Networker.prototype.onJoinSuccess = function(channelName) { - this.game = new Game(this); + this.clientGame = new ClientGame(this); + this.clientGame.loadLevel("default.json") } Networker.prototype.processControlCommand = function(command, options){ @@ -60,7 +61,7 @@ define(["Protocol/Helper", "Chuck/Game"], function(ProtocolHelper, Game) { break; case 'gameCommand': - this.game.processGameCommand(options); + this.clientGame.processGameCommand(options); break; default: diff --git a/lib/Server/Channel.js b/lib/Server/Channel.js index e35f34b..07671b5 100644 --- a/lib/Server/Channel.js +++ b/lib/Server/Channel.js @@ -1,10 +1,9 @@ -define(["Chuck/Game"], function(Game) { +define(["Chuck/ServerGame"], function(ServerGame) { function Channel(name) { this.name = name; this.users = {}; - this.game = new Game(); - // create game here + this.serverGame = new ServerGame(this); } Channel.validateName = function(name){ @@ -19,6 +18,10 @@ define(["Chuck/Game"], function(Game) { delete this.users[user.id]; } + Channel.prototype.sendToAllUsers = function(package) { + console.log("not implemented sendToAllUsers: " + JSON.stringify(package)) + } + return Channel; }); \ No newline at end of file