mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
replaced ){ with ) {
This commit is contained in:
parent
76daceb2e7
commit
551fc943c9
20 changed files with 56 additions and 56 deletions
|
|
@ -12,7 +12,7 @@ function (Channel, CoordinatorLink) {
|
||||||
|
|
||||||
process.on('message', function (message) {
|
process.on('message', function (message) {
|
||||||
|
|
||||||
switch(message){
|
switch(message) {
|
||||||
case 'CREATE':
|
case 'CREATE':
|
||||||
channel = new Channel(coordinatorLink);
|
channel = new Channel(coordinatorLink);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ function (http, nodeStatic) {
|
||||||
var fileServer = new nodeStatic.Server(options.rootDirectory, { cache: options.caching });
|
var fileServer = new nodeStatic.Server(options.rootDirectory, { cache: options.caching });
|
||||||
|
|
||||||
this.server = http.createServer(
|
this.server = http.createServer(
|
||||||
function (req, res){
|
function (req, res) {
|
||||||
req.addListener('end', function () {
|
req.addListener('end', function () {
|
||||||
switch(true) {
|
switch(true) {
|
||||||
case req.url == '/':
|
case req.url == '/':
|
||||||
|
|
@ -37,13 +37,13 @@ function (http, nodeStatic) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case new RegExp(/^\/app/).test(req.url):
|
case new RegExp(/^\/app/).test(req.url):
|
||||||
fileServer.serve(req, res, function (){
|
fileServer.serve(req, res, function () {
|
||||||
self.handleFileError(res)
|
self.handleFileError(res)
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case new RegExp(/^\/static/).test(req.url):
|
case new RegExp(/^\/static/).test(req.url):
|
||||||
fileServer.serve(req, res, function (){
|
fileServer.serve(req, res, function () {
|
||||||
self.handleFileError(res)
|
self.handleFileError(res)
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
@ -58,11 +58,11 @@ function (http, nodeStatic) {
|
||||||
this.server.listen(options.port);
|
this.server.listen(options.port);
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpServer.prototype.getServer = function (){
|
HttpServer.prototype.getServer = function () {
|
||||||
return this.server;
|
return this.server;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpServer.prototype.handleFileError = function (res){
|
HttpServer.prototype.handleFileError = function (res) {
|
||||||
res.writeHead(404, {'Content-Type': 'text/html'});
|
res.writeHead(404, {'Content-Type': 'text/html'});
|
||||||
res.end('<h1>404 not ... found</h1>');
|
res.end('<h1>404 not ... found</h1>');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,19 +15,19 @@ function (io) {
|
||||||
this.init(options);
|
this.init(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
Socket.prototype.init = function (options){
|
Socket.prototype.init = function (options) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.socket.configure('development', function (){
|
this.socket.configure('development', function () {
|
||||||
this.set('log level', options.logLevel);
|
this.set('log level', options.logLevel);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socket.on('connection', function (user){
|
this.socket.on('connection', function (user) {
|
||||||
self.onConnection(user);
|
self.onConnection(user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Socket.prototype.onConnection = function (socketLink){
|
Socket.prototype.onConnection = function (socketLink) {
|
||||||
this.coordinator.createUser(socketLink);
|
this.coordinator.createUser(socketLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
define(function (){
|
define(function () {
|
||||||
|
|
||||||
function Key () {
|
function Key () {
|
||||||
this._active = false;
|
this._active = false;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
define(["Game/Core/Control/InputController", "Game/Client/Control/KeyboardInput"], function (InputController, KeyboardInput){
|
define(["Game/Core/Control/InputController", "Game/Client/Control/KeyboardInput"], function (InputController, KeyboardInput) {
|
||||||
|
|
||||||
function KeyboardController (me, gameController) {
|
function KeyboardController (me, gameController) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
define(["Game/Client/Control/Key"], function (Key){
|
define(["Game/Client/Control/Key"], function (Key) {
|
||||||
|
|
||||||
function KeyboardInput (keyboardController) {
|
function KeyboardInput (keyboardController) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ function (ProtocolHelper, GameController) {
|
||||||
console.log('disconnected. game destroyed. no auto-reconnect');
|
console.log('disconnected. game destroyed. no auto-reconnect');
|
||||||
}
|
}
|
||||||
|
|
||||||
Networker.prototype.join = function (channelName){
|
Networker.prototype.join = function (channelName) {
|
||||||
this.sendCommand('join', channelName);
|
this.sendCommand('join', channelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,17 +31,17 @@ define(['Lib/Vendor/Three', 'Game/Config/Settings'], function (Three, Settings)
|
||||||
this.camera.position.z = 481;
|
this.camera.position.z = 481;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraController.prototype.getCamera = function (){
|
CameraController.prototype.getCamera = function () {
|
||||||
return this.camera;
|
return this.camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraController.prototype.setPosition = function (x, y){
|
CameraController.prototype.setPosition = function (x, y) {
|
||||||
this.camera.position.x = x;
|
this.camera.position.x = x;
|
||||||
this.camera.position.y = y;
|
this.camera.position.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CameraController.prototype.setZoom = function (z){
|
CameraController.prototype.setZoom = function (z) {
|
||||||
this.camera.position.z = z;
|
this.camera.position.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ define(['Game/Config/Settings'], function (Settings) {
|
||||||
debugCanvas: null
|
debugCanvas: null
|
||||||
};
|
};
|
||||||
|
|
||||||
DomController.getCanvasContainer = function (){
|
DomController.getCanvasContainer = function () {
|
||||||
var container = document.getElementById(Settings.CANVAS_DOM_ID);
|
var container = document.getElementById(Settings.CANVAS_DOM_ID);
|
||||||
|
|
||||||
if(container) {
|
if(container) {
|
||||||
|
|
@ -15,14 +15,14 @@ define(['Game/Config/Settings'], function (Settings) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DomController.getCanvas = function (){
|
DomController.getCanvas = function () {
|
||||||
return DomController.canvas;
|
return DomController.canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
DomController.setCanvas = function (canvas){
|
DomController.setCanvas = function (canvas) {
|
||||||
|
|
||||||
var container = DomController.getCanvasContainer();
|
var container = DomController.getCanvasContainer();
|
||||||
if(DomController.canvas){
|
if(DomController.canvas) {
|
||||||
container.removeChild(DomController.canvas);
|
container.removeChild(DomController.canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,14 +30,14 @@ define(['Game/Config/Settings'], function (Settings) {
|
||||||
container.appendChild(canvas);
|
container.appendChild(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
DomController.getDebugCanvas = function (){
|
DomController.getDebugCanvas = function () {
|
||||||
return DomController.debugCanvas;
|
return DomController.debugCanvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
DomController.createDebugCanvas = function (){
|
DomController.createDebugCanvas = function () {
|
||||||
|
|
||||||
var container = DomController.getCanvasContainer();
|
var container = DomController.getCanvasContainer();
|
||||||
if(DomController.debugCanvas){
|
if(DomController.debugCanvas) {
|
||||||
container.removeChild(DomController.debugCanvas);
|
container.removeChild(DomController.debugCanvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ var requires = [
|
||||||
"Game/Client/View/CameraController"
|
"Game/Client/View/CameraController"
|
||||||
];
|
];
|
||||||
|
|
||||||
define(requires, function (DomController, Three, Settings, CameraController){
|
define(requires, function (DomController, Three, Settings, CameraController) {
|
||||||
|
|
||||||
function ViewController (){
|
function ViewController () {
|
||||||
|
|
||||||
this.mesh = null;
|
this.mesh = null;
|
||||||
this.scene = null;
|
this.scene = null;
|
||||||
|
|
@ -25,7 +25,7 @@ define(requires, function (DomController, Three, Settings, CameraController){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewController.prototype.init = function (){
|
ViewController.prototype.init = function () {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ define(requires, function (DomController, Three, Settings, CameraController){
|
||||||
|
|
||||||
DomController.setCanvas(this.renderer.domElement);
|
DomController.setCanvas(this.renderer.domElement);
|
||||||
|
|
||||||
if(Settings.DEBUG_MODE){
|
if(Settings.DEBUG_MODE) {
|
||||||
DomController.createDebugCanvas();
|
DomController.createDebugCanvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,12 +61,12 @@ define(requires, function (DomController, Three, Settings, CameraController){
|
||||||
this.scene.add(directionalLight);
|
this.scene.add(directionalLight);
|
||||||
|
|
||||||
|
|
||||||
this.createMesh(100, 100, 100, 100, 'static/img/100.png', function (mesh){
|
this.createMesh(100, 100, 100, 100, 'static/img/100.png', function (mesh) {
|
||||||
self.mesh = mesh;
|
self.mesh = mesh;
|
||||||
self.scene.add(mesh);
|
self.scene.add(mesh);
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
this.createMesh(50, 50, 200, 100, 'static/img/100.png', function (mesh){
|
this.createMesh(50, 50, 200, 100, 'static/img/100.png', function (mesh) {
|
||||||
self.scene.add(mesh);
|
self.scene.add(mesh);
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
@ -93,7 +93,7 @@ define(requires, function (DomController, Three, Settings, CameraController){
|
||||||
|
|
||||||
ViewController.prototype.createMesh = function (width, height, x, y, imgPath, callback) {
|
ViewController.prototype.createMesh = function (width, height, x, y, imgPath, callback) {
|
||||||
var textureImg = new Image();
|
var textureImg = new Image();
|
||||||
textureImg.onload = function (){
|
textureImg.onload = function () {
|
||||||
var material = new Three.MeshLambertMaterial({
|
var material = new Three.MeshLambertMaterial({
|
||||||
map: Three.ImageUtils.loadTexture(imgPath)
|
map: Three.ImageUtils.loadTexture(imgPath)
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
define(function (){
|
define(function () {
|
||||||
|
|
||||||
function InputController (player) {
|
function InputController (player) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
define(["Lib/Vendor/Box2D", "Game/Config/Settings", "Game/Core/Collision/Detector"], function (Box2D, Settings, CollisionDetector) {
|
define(["Lib/Vendor/Box2D", "Game/Config/Settings", "Game/Core/Collision/Detector"], function (Box2D, Settings, CollisionDetector) {
|
||||||
|
|
||||||
function Doll (physicsEngine, id){
|
function Doll (physicsEngine, id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.physicsEngine = physicsEngine;
|
this.physicsEngine = physicsEngine;
|
||||||
this.body;
|
this.body;
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,17 @@ function (Parser) {
|
||||||
|
|
||||||
var Helper = {}
|
var Helper = {}
|
||||||
|
|
||||||
Helper.encodeCommand = function (command, options){
|
Helper.encodeCommand = function (command, options) {
|
||||||
return Parser.encode(Helper.assemble(command, options));
|
return Parser.encode(Helper.assemble(command, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
Helper.assemble = function (command, options){
|
Helper.assemble = function (command, options) {
|
||||||
var commands = {};
|
var commands = {};
|
||||||
commands[command] = options || null;
|
commands[command] = options || null;
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
Helper.runCommands = function (message, callback){
|
Helper.runCommands = function (message, callback) {
|
||||||
var commands = Parser.decode(message);
|
var commands = Parser.decode(message);
|
||||||
|
|
||||||
for(var command in commands) {
|
for(var command in commands) {
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ function () {
|
||||||
|
|
||||||
var Parser = {};
|
var Parser = {};
|
||||||
|
|
||||||
Parser.encode = function (message){
|
Parser.encode = function (message) {
|
||||||
return JSON.stringify(message);
|
return JSON.stringify(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Parser.decode = function (message){
|
Parser.decode = function (message) {
|
||||||
return JSON.parse(message);
|
return JSON.parse(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel.validateName = function (name){
|
Channel.validateName = function (name) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
Channel.prototype.forward = function (target, message) {
|
Channel.prototype.forward = function (target, message) {
|
||||||
for(var command in message) {
|
for(var command in message) {
|
||||||
if(typeof target[command] == 'function'){
|
if(typeof target[command] == 'function') {
|
||||||
target[command].call(target, message[command]);
|
target[command].call(target, message[command]);
|
||||||
} else {
|
} else {
|
||||||
throw 'trying to call undefined function ' + target[command];
|
throw 'trying to call undefined function ' + target[command];
|
||||||
|
|
@ -67,7 +67,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Channel.prototype.addUser = function (user){
|
Channel.prototype.addUser = function (user) {
|
||||||
var userIds = Object.keys(this.users);
|
var userIds = Object.keys(this.users);
|
||||||
|
|
||||||
this.users[user.id] = user;
|
this.users[user.id] = user;
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ function (Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, No
|
||||||
do {
|
do {
|
||||||
var userData = body.GetUserData();
|
var userData = body.GetUserData();
|
||||||
|
|
||||||
if(userData && body.IsAwake()){
|
if(userData && body.IsAwake()) {
|
||||||
update[userData] = {
|
update[userData] = {
|
||||||
p: body.GetPosition(),
|
p: body.GetPosition(),
|
||||||
a: body.GetAngle(),
|
a: body.GetAngle(),
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ function (Parent, ProtocolHelper, NotificationCenter) {
|
||||||
|
|
||||||
User.prototype = Object.create(Parent.prototype);
|
User.prototype = Object.create(Parent.prototype);
|
||||||
|
|
||||||
User.prototype.init = function (socketLink){
|
User.prototype.init = function (socketLink) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ define([
|
||||||
|
|
||||||
function (Settings) {
|
function (Settings) {
|
||||||
|
|
||||||
var requestAnimFrame = (function (){
|
var requestAnimFrame = (function () {
|
||||||
|
|
||||||
var _setTimeout = function ( callback ){
|
var _setTimeout = function ( callback ) {
|
||||||
setTimeout(callback, Settings.BOX2D_TIME_STEP * 1000);
|
setTimeout(callback, Settings.BOX2D_TIME_STEP * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,25 +13,25 @@ function (User, Channel, childProcess) {
|
||||||
this.lobbyUsers = {};
|
this.lobbyUsers = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinator.prototype.createUser = function (socketLink){
|
Coordinator.prototype.createUser = function (socketLink) {
|
||||||
var user = new User(socketLink, this);
|
var user = new User(socketLink, this);
|
||||||
this.assignUserToLobby(user);
|
this.assignUserToLobby(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinator.prototype.assignUserToLobby = function (user){
|
Coordinator.prototype.assignUserToLobby = function (user) {
|
||||||
if(user.channelProcess) {
|
if(user.channelProcess) {
|
||||||
//user.channel.releaseUser(user); -> generate message
|
//user.channel.releaseUser(user); -> generate message
|
||||||
}
|
}
|
||||||
this.lobbyUsers[user.id] = user;
|
this.lobbyUsers[user.id] = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinator.prototype.assignUserToChannel = function (user, channelName){
|
Coordinator.prototype.assignUserToChannel = function (user, channelName) {
|
||||||
|
|
||||||
if(user.channelProcess) {
|
if(user.channelProcess) {
|
||||||
//user.channel.releaseUser(user); -> generate message
|
//user.channel.releaseUser(user); -> generate message
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Channel.validateName(channelName)){
|
if(!Channel.validateName(channelName)) {
|
||||||
//TODO send validation error
|
//TODO send validation error
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +62,7 @@ function (User, Channel, childProcess) {
|
||||||
delete this.lobbyUsers[user.id];
|
delete this.lobbyUsers[user.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinator.prototype.removeUser = function (user){
|
Coordinator.prototype.removeUser = function (user) {
|
||||||
delete this.lobbyUsers[user.id];
|
delete this.lobbyUsers[user.id];
|
||||||
if(user.channelProcess) {
|
if(user.channelProcess) {
|
||||||
//user.channel.releaseUser(user); -> generate message
|
//user.channel.releaseUser(user); -> generate message
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ function (Parent, ProtocolHelper) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
socketLink.on('message', function (message){
|
socketLink.on('message', function (message) {
|
||||||
self.onMessage(message);
|
self.onMessage(message);
|
||||||
});
|
});
|
||||||
socketLink.on('disconnect', function (){
|
socketLink.on('disconnect', function () {
|
||||||
self.onDisconnect();
|
self.onDisconnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -27,18 +27,18 @@ function (Parent, ProtocolHelper) {
|
||||||
this.channelProcess = channelProcess;
|
this.channelProcess = channelProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.onMessage = function (message){
|
User.prototype.onMessage = function (message) {
|
||||||
var self = this;
|
var self = this;
|
||||||
ProtocolHelper.runCommands(message, function (command, options){
|
ProtocolHelper.runCommands(message, function (command, options) {
|
||||||
self.processControlCommand(command, options);
|
self.processControlCommand(command, options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.onDisconnect = function (){
|
User.prototype.onDisconnect = function () {
|
||||||
this.coordinator.removeUser(this);
|
this.coordinator.removeUser(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.processControlCommand = function (command, options){
|
User.prototype.processControlCommand = function (command, options) {
|
||||||
switch(command) {
|
switch(command) {
|
||||||
|
|
||||||
case 'join':
|
case 'join':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue