From 76391c2c5e26ae99d93d0dc0edc3741a81ee8728 Mon Sep 17 00:00:00 2001 From: logsol Date: Sun, 22 Jul 2012 13:05:29 +0200 Subject: [PATCH] fixing up the branch --- app/Bootstrap/Client.js | 2 +- app/Game/Client/Networker.js | 9 +++++++-- app/Game/Core/GameController.js | 1 + app/Game/Server/Channel.js | 11 +++++------ app/Game/Server/GameController.js | 5 ++++- app/Lib/Vendor/Three.js | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) mode change 100644 => 100755 app/Game/Core/GameController.js diff --git a/app/Bootstrap/Client.js b/app/Bootstrap/Client.js index 79a50c1..9e4ed07 100755 --- a/app/Bootstrap/Client.js +++ b/app/Bootstrap/Client.js @@ -7,7 +7,7 @@ function(Networker, SocketIO) { function Client(location) { this.socket = SocketIO.connect(location); - this.networker = new Networker(socket); + this.networker = new Networker(this.socket); } return Client; diff --git a/app/Game/Client/Networker.js b/app/Game/Client/Networker.js index 00b873f..721f76d 100755 --- a/app/Game/Client/Networker.js +++ b/app/Game/Client/Networker.js @@ -1,4 +1,9 @@ -define(["Game/Core/Protocol/Helper", "Game/Client/GameController"], function(ProtocolHelper, GameController) { +define([ + "Game/Core/Protocol/Helper", + "Game/Client/GameController" +], + +function(ProtocolHelper, GameController) { function Networker(socketLink) { this.socketLink = socketLink; @@ -36,7 +41,7 @@ define(["Game/Core/Protocol/Helper", "Game/Client/GameController"], function(Pro } Networker.prototype.onDisconnect = function() { - this.gameController.destruct(); + if(this.gameController) this.gameController.destruct(); this.gameController = null; } diff --git a/app/Game/Core/GameController.js b/app/Game/Core/GameController.js old mode 100644 new mode 100755 index 75f8704..5f26592 --- a/app/Game/Core/GameController.js +++ b/app/Game/Core/GameController.js @@ -6,6 +6,7 @@ define([ function(Engine, Level) { function GameController(physicsEngine) { + console.log('constructor called'); this.players = {}; if (! physicsEngine instanceof Engine) { diff --git a/app/Game/Server/Channel.js b/app/Game/Server/Channel.js index 9a3715f..867e85a 100755 --- a/app/Game/Server/Channel.js +++ b/app/Game/Server/Channel.js @@ -8,9 +8,8 @@ function(GameController, NotificationCenter) { function Channel(name) { this.name = name; this.users = {}; - this.serverGame = new GameController(); - console.log("server game " + this.serverGame); - this.serverGame.loadLevel("default.json"); + this.gameController = new GameController(); + this.gameController.loadLevel("default.json"); var self = this; NotificationCenter.on("processGameCommandFromUser", function(topic, args) { @@ -30,11 +29,11 @@ function(GameController, NotificationCenter) { user.sendCommand('joinSuccess', {channelName: this.name, id: user.id, userIds: userIds}); this.sendCommandToAllUsersExcept('userJoined', user.id, user); - this.serverGame.createPlayerForUser(user) + this.gameController.createPlayerForUser(user) } Channel.prototype.releaseUser = function(user) { - this.serverGame.userIdLeft(user.id); + this.gameController.userIdLeft(user.id); this.sendCommandToAllUsersExcept("userLeft", user.id, user); delete this.users[user.id]; @@ -55,7 +54,7 @@ function(GameController, NotificationCenter) { } Channel.prototype.processGameCommandFromUser = function(command, options, user) { - this.serverGame.progressGameCommandFromUser(command, options, user); + this.gameController.progressGameCommandFromUser(command, options, user); } return Channel; diff --git a/app/Game/Server/GameController.js b/app/Game/Server/GameController.js index 603f83b..3cc2bd4 100755 --- a/app/Game/Server/GameController.js +++ b/app/Game/Server/GameController.js @@ -10,7 +10,7 @@ define([ function(Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, NotificationCenter) { function GameController () { - Parent.apply(this, new PhysicsEngine()); + Parent.call(this, new PhysicsEngine()); this.inputControllers = {}; @@ -18,6 +18,9 @@ function(Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, Not this.updateWorld(); } + GameController.prototype = Object.create(Parent.prototype); + console.log(GameController.loadLevel); + GameController.prototype.update = function() { requestAnimFrame(this.update.bind(this)); diff --git a/app/Lib/Vendor/Three.js b/app/Lib/Vendor/Three.js index f12e072..ee09a6e 100755 --- a/app/Lib/Vendor/Three.js +++ b/app/Lib/Vendor/Three.js @@ -1,3 +1,3 @@ -define(["Vendor/Three/Three"], function() { +define(["Lib/Vendor/Three/Three"], function() { return THREE; }) \ No newline at end of file