mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixing up the branch
This commit is contained in:
parent
005fb57c31
commit
76391c2c5e
6 changed files with 19 additions and 11 deletions
|
|
@ -7,7 +7,7 @@ function(Networker, SocketIO) {
|
||||||
|
|
||||||
function Client(location) {
|
function Client(location) {
|
||||||
this.socket = SocketIO.connect(location);
|
this.socket = SocketIO.connect(location);
|
||||||
this.networker = new Networker(socket);
|
this.networker = new Networker(this.socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Client;
|
return Client;
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
function Networker(socketLink) {
|
||||||
this.socketLink = socketLink;
|
this.socketLink = socketLink;
|
||||||
|
|
@ -36,7 +41,7 @@ define(["Game/Core/Protocol/Helper", "Game/Client/GameController"], function(Pro
|
||||||
}
|
}
|
||||||
|
|
||||||
Networker.prototype.onDisconnect = function() {
|
Networker.prototype.onDisconnect = function() {
|
||||||
this.gameController.destruct();
|
if(this.gameController) this.gameController.destruct();
|
||||||
this.gameController = null;
|
this.gameController = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
1
app/Game/Core/GameController.js
Normal file → Executable file
1
app/Game/Core/GameController.js
Normal file → Executable file
|
|
@ -6,6 +6,7 @@ define([
|
||||||
function(Engine, Level) {
|
function(Engine, Level) {
|
||||||
|
|
||||||
function GameController(physicsEngine) {
|
function GameController(physicsEngine) {
|
||||||
|
console.log('constructor called');
|
||||||
this.players = {};
|
this.players = {};
|
||||||
|
|
||||||
if (! physicsEngine instanceof Engine) {
|
if (! physicsEngine instanceof Engine) {
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,8 @@ function(GameController, NotificationCenter) {
|
||||||
function Channel(name) {
|
function Channel(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.users = {};
|
this.users = {};
|
||||||
this.serverGame = new GameController();
|
this.gameController = new GameController();
|
||||||
console.log("server game " + this.serverGame);
|
this.gameController.loadLevel("default.json");
|
||||||
this.serverGame.loadLevel("default.json");
|
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
NotificationCenter.on("processGameCommandFromUser", function(topic, args) {
|
NotificationCenter.on("processGameCommandFromUser", function(topic, args) {
|
||||||
|
|
@ -30,11 +29,11 @@ function(GameController, NotificationCenter) {
|
||||||
user.sendCommand('joinSuccess', {channelName: this.name, id: user.id, userIds: userIds});
|
user.sendCommand('joinSuccess', {channelName: this.name, id: user.id, userIds: userIds});
|
||||||
this.sendCommandToAllUsersExcept('userJoined', user.id, user);
|
this.sendCommandToAllUsersExcept('userJoined', user.id, user);
|
||||||
|
|
||||||
this.serverGame.createPlayerForUser(user)
|
this.gameController.createPlayerForUser(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel.prototype.releaseUser = function(user) {
|
Channel.prototype.releaseUser = function(user) {
|
||||||
this.serverGame.userIdLeft(user.id);
|
this.gameController.userIdLeft(user.id);
|
||||||
|
|
||||||
this.sendCommandToAllUsersExcept("userLeft", user.id, user);
|
this.sendCommandToAllUsersExcept("userLeft", user.id, user);
|
||||||
delete this.users[user.id];
|
delete this.users[user.id];
|
||||||
|
|
@ -55,7 +54,7 @@ function(GameController, NotificationCenter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel.prototype.processGameCommandFromUser = function(command, options, user) {
|
Channel.prototype.processGameCommandFromUser = function(command, options, user) {
|
||||||
this.serverGame.progressGameCommandFromUser(command, options, user);
|
this.gameController.progressGameCommandFromUser(command, options, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Channel;
|
return Channel;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ define([
|
||||||
function(Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, NotificationCenter) {
|
function(Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, NotificationCenter) {
|
||||||
|
|
||||||
function GameController () {
|
function GameController () {
|
||||||
Parent.apply(this, new PhysicsEngine());
|
Parent.call(this, new PhysicsEngine());
|
||||||
|
|
||||||
this.inputControllers = {};
|
this.inputControllers = {};
|
||||||
|
|
||||||
|
|
@ -18,6 +18,9 @@ function(Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, Not
|
||||||
this.updateWorld();
|
this.updateWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameController.prototype = Object.create(Parent.prototype);
|
||||||
|
console.log(GameController.loadLevel);
|
||||||
|
|
||||||
GameController.prototype.update = function() {
|
GameController.prototype.update = function() {
|
||||||
|
|
||||||
requestAnimFrame(this.update.bind(this));
|
requestAnimFrame(this.update.bind(this));
|
||||||
|
|
|
||||||
2
app/Lib/Vendor/Three.js
vendored
2
app/Lib/Vendor/Three.js
vendored
|
|
@ -1,3 +1,3 @@
|
||||||
define(["Vendor/Three/Three"], function() {
|
define(["Lib/Vendor/Three/Three"], function() {
|
||||||
return THREE;
|
return THREE;
|
||||||
})
|
})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue