mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
57 lines
1.3 KiB
JavaScript
Executable file
57 lines
1.3 KiB
JavaScript
Executable file
define([
|
|
"Game/Core/Physics/Engine",
|
|
"Game/Core/Loader/Level",
|
|
"Game/Core/Player"
|
|
],
|
|
|
|
function(Engine, Level, Player) {
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
GameController.prototype.userJoined = function(user) {
|
|
var player = new Player(user.id, this.physicsEngine);
|
|
this.players[user.id] = player;
|
|
return player;
|
|
}
|
|
|
|
GameController.prototype.userLeft = function(user) {
|
|
var player = this.players[user.id];
|
|
player.destroy();
|
|
delete this.players[user.id];
|
|
}
|
|
|
|
*/
|
|
|
|
return GameController;
|
|
});
|