mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
implemented level restart
This commit is contained in:
parent
81611050d2
commit
3edd664412
12 changed files with 104 additions and 47 deletions
|
|
@ -4,35 +4,50 @@ define([
|
|||
"Game/" + GLOBALS.context + "/Player"
|
||||
],
|
||||
|
||||
function (Engine, Level, Player) {
|
||||
function (PhysicsEngine, Level, Player) {
|
||||
|
||||
function GameController (physicsEngine) {
|
||||
function GameController () {
|
||||
this.players = {};
|
||||
this.gameObjects = {
|
||||
animated: [],
|
||||
fixed: []
|
||||
};
|
||||
|
||||
if (! physicsEngine instanceof Engine) {
|
||||
throw physicsEngine + " is not of type Engine";
|
||||
}
|
||||
this.levelPath = null;
|
||||
|
||||
this.physicsEngine = physicsEngine;
|
||||
this.physicsEngine = new PhysicsEngine();
|
||||
this.physicsEngine.setCollisionDetector();
|
||||
|
||||
this.update();
|
||||
}
|
||||
|
||||
GameController.prototype.update = function() {
|
||||
|
||||
};
|
||||
|
||||
GameController.prototype.getPhysicsEngine = function () {
|
||||
return this.physicsEngine;
|
||||
}
|
||||
|
||||
GameController.prototype.loadLevel = function (path) {
|
||||
this.levelPath = path;
|
||||
|
||||
if (this.level) {
|
||||
this.level.unload();
|
||||
this.level.destroy();
|
||||
this.gameObjects = {
|
||||
animated: [],
|
||||
fixed: []
|
||||
};
|
||||
}
|
||||
|
||||
this.level = new Level(path, this.physicsEngine, this.gameObjects);
|
||||
this.level.loadLevelInToEngine();
|
||||
}
|
||||
|
||||
GameController.prototype.onResetLevel = function() {
|
||||
this.loadLevel(this.levelPath);
|
||||
};
|
||||
|
||||
|
||||
GameController.prototype.destroy = function () {
|
||||
for(var player in this.players) {
|
||||
this.players[player].destroy();
|
||||
|
|
@ -53,6 +68,5 @@ function (Engine, Level, Player) {
|
|||
return new Player(user.id, this.physicsEngine);
|
||||
};
|
||||
|
||||
|
||||
return GameController;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue