mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed input controllerism - fixes #28
This commit is contained in:
parent
a59a258ad6
commit
f5eacb6335
13 changed files with 163 additions and 223 deletions
|
|
@ -1,19 +1,22 @@
|
|||
define([
|
||||
"Game/Core/Control/InputController",
|
||||
"Game/Core/Control/PlayerController",
|
||||
"Game/Core/NotificationCenter",
|
||||
"Game/Core/Protocol/Parser"
|
||||
],
|
||||
|
||||
function(Parent, NotificationCenter, Parser) {
|
||||
|
||||
function InputController(player) {
|
||||
function PlayerController(player) {
|
||||
|
||||
Parent.call(this, player);
|
||||
}
|
||||
|
||||
InputController.prototype = Object.create(Parent.prototype);
|
||||
PlayerController.prototype = Object.create(Parent.prototype);
|
||||
|
||||
InputController.prototype.applyCommand = function(options) {
|
||||
/*
|
||||
* retrieves move (and other) commands from client and executes them at the server
|
||||
*/
|
||||
PlayerController.prototype.applyCommand = function(options) {
|
||||
var message;
|
||||
if (typeof options == "string") {
|
||||
message = Parser.decode(options);
|
||||
|
|
@ -26,6 +29,6 @@ function(Parent, NotificationCenter, Parser) {
|
|||
}
|
||||
};
|
||||
|
||||
return InputController;
|
||||
return PlayerController;
|
||||
|
||||
});
|
||||
|
|
@ -2,13 +2,13 @@ define([
|
|||
"Game/Core/GameController",
|
||||
"Game/Core/Physics/Engine",
|
||||
"Game/Config/Settings",
|
||||
"Game/Server/Control/InputController",
|
||||
"Game/Server/Control/PlayerController",
|
||||
"Lib/Utilities/RequestAnimFrame",
|
||||
"Game/Core/NotificationCenter",
|
||||
"Game/Server/Player"
|
||||
],
|
||||
|
||||
function (Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, NotificationCenter, Player) {
|
||||
function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, NotificationCenter, Player) {
|
||||
|
||||
function GameController (channel) {
|
||||
Parent.call(this, new PhysicsEngine());
|
||||
|
|
@ -62,7 +62,7 @@ function (Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, No
|
|||
|
||||
GameController.prototype.createPlayer = function(user) {
|
||||
var player = new Player(user.id, this.physicsEngine);
|
||||
player.setInputController(new InputController(player))
|
||||
player.setPlayerController(new PlayerController(player))
|
||||
|
||||
return player;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,19 +3,7 @@ define([
|
|||
],
|
||||
|
||||
function(Parent) {
|
||||
|
||||
function Player(id, physicsEngine) {
|
||||
Parent.call(this, id, physicsEngine);
|
||||
|
||||
this.inputController = null;
|
||||
}
|
||||
|
||||
Player.prototype = Object.create(Parent.prototype);
|
||||
|
||||
Player.prototype.setInputController = function(inputController) {
|
||||
this.inputController = inputController;
|
||||
}
|
||||
|
||||
return Player;
|
||||
return Parent;
|
||||
|
||||
});
|
||||
|
|
@ -38,7 +38,7 @@ function(Parent, NotificationCenter, ProtocolHelper) {
|
|||
// User command callbacks
|
||||
|
||||
User.prototype.onGameCommand = function(command) {
|
||||
this.player.inputController.applyCommand(command);
|
||||
this.player.playerController.applyCommand(command);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue