fixing up the branch

This commit is contained in:
logsol 2012-07-22 13:05:29 +02:00
parent 005fb57c31
commit 76391c2c5e
6 changed files with 19 additions and 11 deletions

View file

@ -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;

View file

@ -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;
}

1
app/Game/Core/GameController.js Normal file → Executable file
View file

@ -6,6 +6,7 @@ define([
function(Engine, Level) {
function GameController(physicsEngine) {
console.log('constructor called');
this.players = {};
if (! physicsEngine instanceof Engine) {

View file

@ -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;

View file

@ -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));

View file

@ -1,3 +1,3 @@
define(["Vendor/Three/Three"], function() {
define(["Lib/Vendor/Three/Three"], function() {
return THREE;
})