mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Merge branch 'restructuring' of github.com:logsol/chuck.js into restructuring
This commit is contained in:
commit
ec84e8d025
4 changed files with 58 additions and 7 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
var requires = [
|
define([
|
||||||
"Game/Client/View/ViewController",
|
"Game/Client/View/ViewController",
|
||||||
"Game/Core/Physics/Engine",
|
"Game/Core/Physics/Engine",
|
||||||
"Game/Core/Player",
|
"Game/Core/Player",
|
||||||
|
|
@ -7,9 +7,9 @@ var requires = [
|
||||||
"Game/Core/Loader/Level",
|
"Game/Core/Loader/Level",
|
||||||
"Lib/Vendor/Box2D",
|
"Lib/Vendor/Box2D",
|
||||||
"Lib/Utilities/RequestAnimFrame"
|
"Lib/Utilities/RequestAnimFrame"
|
||||||
];
|
],
|
||||||
|
|
||||||
define(requires, function(ViewController, PhysicsEngine, Player, KeyboardController, Settings, Level, Box2D, requestAnimFrame) {
|
function(ViewController, PhysicsEngine, Player, KeyboardController, Settings, Level, Box2D, requestAnimFrame) {
|
||||||
|
|
||||||
function GameController (clientGame) {
|
function GameController (clientGame) {
|
||||||
this.clientGame = clientGame;
|
this.clientGame = clientGame;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
define([
|
||||||
|
"Game/Core/Physics/Engine"
|
||||||
|
"Game/Core/Loader/Level"
|
||||||
|
],
|
||||||
|
|
||||||
|
function(Engine, Level, ) {
|
||||||
|
|
||||||
|
function GameController(physicsEngine) {
|
||||||
|
this.players = {};
|
||||||
|
|
||||||
|
if (! physicsEngine instanceof Engine) {
|
||||||
|
throw physicsEngine + " is not of type Engine";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.physicsEngine = physicsEngine;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameController.prototype.getPhysicsEngine = function() {
|
||||||
|
return this.physicsEngine;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameController.prototype.loadLevel = function(path) {
|
||||||
|
if (this.level) {
|
||||||
|
this.level.unload();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.level = new Level(path, this.physicsEngine);
|
||||||
|
this.level.loadLevelInToEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
GameController.prototype.destroy = function() {
|
||||||
|
for(var player in this.players) {
|
||||||
|
this.players[player].destroy();
|
||||||
|
}
|
||||||
|
delete this.players;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameController.prototype.userJoined = function(user) {
|
||||||
|
var player = new Player(this.physicsEngine, id);
|
||||||
|
this.players[user.id] = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameController.prototype.userLeft = function(user) {
|
||||||
|
var player = this.players[user.id];
|
||||||
|
player.destroy();
|
||||||
|
delete this.players[user.id];
|
||||||
|
}
|
||||||
|
|
||||||
|
return GameController;
|
||||||
|
});
|
||||||
|
|
@ -6,9 +6,9 @@ define([
|
||||||
"Chuck/Loader/Level",
|
"Chuck/Loader/Level",
|
||||||
"Chuck/Control/InputController",
|
"Chuck/Control/InputController",
|
||||||
"RequestAnimationFrame"
|
"RequestAnimationFrame"
|
||||||
],
|
],
|
||||||
|
|
||||||
function(PhysicsEngine, Settings, Player, Box2D, Level, InputController, requestAnimFrame){
|
function(PhysicsEngine, Settings, Player, Box2D, Level, InputController, requestAnimFrame) {
|
||||||
|
|
||||||
function GameController (channel) {
|
function GameController (channel) {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
|
|
@ -109,4 +109,4 @@ function(PhysicsEngine, Settings, Player, Box2D, Level, InputController, request
|
||||||
}
|
}
|
||||||
|
|
||||||
return GameController;
|
return GameController;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -25,5 +25,6 @@
|
||||||
"node": "*"
|
"node": "*"
|
||||||
},
|
},
|
||||||
"config": { "port": "1234" },
|
"config": { "port": "1234" },
|
||||||
"private": true
|
"private": true,
|
||||||
|
"scripts": {"start": "node app.js"}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue