mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
ground work for different users on server and players on client
This commit is contained in:
parent
e37d1eeb2e
commit
2cb401bbd3
9 changed files with 122 additions and 54 deletions
|
|
@ -12,22 +12,18 @@ var requires = [
|
|||
define(requires,
|
||||
function(ViewController, PhysicsEngine, Player, InputControlUnit, Settings, Box2D, Level, requestAnimFrame) {
|
||||
|
||||
function ClientGame () {
|
||||
function ClientProcessor () {
|
||||
this.init();
|
||||
};
|
||||
|
||||
ClientGame.prototype.init = function() {
|
||||
ClientProcessor.prototype.init = function() {
|
||||
this.viewController = new ViewController();
|
||||
this.physicsEngine = new PhysicsEngine();
|
||||
this.me = new Player(this.physicsEngine, null);
|
||||
this.me.spawn(100, 0);
|
||||
this.inputControlUnit = new InputControlUnit(this.me);
|
||||
this.physicsEngine.setCollisionDetector(this.me);
|
||||
|
||||
this.update();
|
||||
}
|
||||
|
||||
ClientGame.prototype.loadLevel = function(path) {
|
||||
ClientProcessor.prototype.loadLevel = function(path) {
|
||||
if (this.level) {
|
||||
this.level.unload();
|
||||
}
|
||||
|
|
@ -36,27 +32,41 @@ define(requires,
|
|||
this.level.loadLevelInToEngine();
|
||||
}
|
||||
|
||||
ClientGame.prototype.getPhysicsEngine = function() {
|
||||
ClientProcessor.prototype.getPhysicsEngine = function() {
|
||||
return this.physicsEngine;
|
||||
}
|
||||
|
||||
ClientGame.prototype.getMe = function() {
|
||||
ClientProcessor.prototype.getMe = function() {
|
||||
return this.me;
|
||||
}
|
||||
|
||||
ClientGame.prototype.update = function() {
|
||||
ClientProcessor.prototype.update = function() {
|
||||
|
||||
requestAnimFrame(this.update.bind(this));
|
||||
|
||||
this.physicsEngine.update();
|
||||
this.viewController.update();
|
||||
this.inputControlUnit.update();
|
||||
this.me.update();
|
||||
if(this.me) {
|
||||
this.inputControlUnit.update();
|
||||
this.me.update();
|
||||
}
|
||||
}
|
||||
|
||||
ClientGame.prototype.destruct = function() {
|
||||
ClientProcessor.prototype.destruct = function() {
|
||||
|
||||
}
|
||||
|
||||
return ClientGame;
|
||||
ClientProcessor.prototype.spawnNewPlayerWithId = function(id) {
|
||||
var player = new Player(this.physicsEngine, id, null);
|
||||
player.spawn(100, 0);
|
||||
this.physicsEngine.setCollisionDetector(player);
|
||||
return player;
|
||||
}
|
||||
|
||||
ClientProcessor.prototype.spawnMeWithId = function(id) {
|
||||
this.me = this.spawnNewPlayerWithId(id);
|
||||
this.inputControlUnit = new InputControlUnit(this.me);
|
||||
}
|
||||
|
||||
return ClientProcessor;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue