mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
changed function( to function (
This commit is contained in:
parent
26f3d22db7
commit
7e5eeb0a27
36 changed files with 209 additions and 209 deletions
|
|
@ -3,7 +3,7 @@ define([
|
|||
"Game/Core/Collision/Detector"
|
||||
],
|
||||
|
||||
function(Box2D, Parent) {
|
||||
function (Box2D, Parent) {
|
||||
|
||||
function Detector(me) {
|
||||
Parent.call(this);
|
||||
|
|
@ -12,7 +12,7 @@ function(Box2D, Parent) {
|
|||
|
||||
Detector.prototype = Object.create(Parent.prototype);
|
||||
|
||||
Detector.prototype.handleStand = function(point, isColliding) {
|
||||
Detector.prototype.handleStand = function (point, isColliding) {
|
||||
if (point.GetFixtureA().GetUserData() == Detector.IDENTIFIER.PLAYER_FOOT_SENSOR
|
||||
|| point.GetFixtureB().GetUserData() == Detector.IDENTIFIER.PLAYER_FOOT_SENSOR) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
define(function(){
|
||||
define(function (){
|
||||
|
||||
function Key () {
|
||||
this._active = false;
|
||||
|
|
@ -9,51 +9,51 @@ define(function(){
|
|||
this._keyFrameFunction = null;
|
||||
}
|
||||
|
||||
Key.prototype.setActivityUpdateStatus = function(active) {
|
||||
Key.prototype.setActivityUpdateStatus = function (active) {
|
||||
this._activityUpdateStatus = active;
|
||||
}
|
||||
|
||||
Key.prototype.getActivityUpdateStatus = function() {
|
||||
Key.prototype.getActivityUpdateStatus = function () {
|
||||
return this._activityUpdateStatus;
|
||||
}
|
||||
|
||||
Key.prototype.setActivityUpdateNeeded = function(need) {
|
||||
Key.prototype.setActivityUpdateNeeded = function (need) {
|
||||
this._activityUpdateNeeded = need;
|
||||
}
|
||||
|
||||
Key.prototype.getActivityUpdateNeeded = function() {
|
||||
Key.prototype.getActivityUpdateNeeded = function () {
|
||||
return this._activityUpdateNeeded;
|
||||
}
|
||||
|
||||
Key.prototype.setActive = function(active) {
|
||||
Key.prototype.setActive = function (active) {
|
||||
this._active = active;
|
||||
}
|
||||
|
||||
Key.prototype.getActive = function() {
|
||||
Key.prototype.getActive = function () {
|
||||
return this._active;
|
||||
}
|
||||
|
||||
Key.prototype.setKeyDownFunction = function(f) {
|
||||
Key.prototype.setKeyDownFunction = function (f) {
|
||||
this._keyDownFunction = f;
|
||||
}
|
||||
|
||||
Key.prototype.getKeyDownFunction = function() {
|
||||
Key.prototype.getKeyDownFunction = function () {
|
||||
return this._keyDownFunction;
|
||||
}
|
||||
|
||||
Key.prototype.setKeyUpFunction = function(f) {
|
||||
Key.prototype.setKeyUpFunction = function (f) {
|
||||
this._keyUpFunction = f;
|
||||
}
|
||||
|
||||
Key.prototype.getKeyUpFunction = function() {
|
||||
Key.prototype.getKeyUpFunction = function () {
|
||||
return this._keyUpFunction;
|
||||
}
|
||||
|
||||
Key.prototype.setKeyFrameFunction = function(f) {
|
||||
Key.prototype.setKeyFrameFunction = function (f) {
|
||||
this._keyFrameFunction = f;
|
||||
}
|
||||
|
||||
Key.prototype.getKeyFrameFunction = function() {
|
||||
Key.prototype.getKeyFrameFunction = function () {
|
||||
return this._keyFrameFunction;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ define(["Game/Core/Control/InputController", "Game/Client/Control/KeyboardInput"
|
|||
this.init(keys);
|
||||
}
|
||||
|
||||
KeyboardController.prototype.init = function(keys) {
|
||||
KeyboardController.prototype.init = function (keys) {
|
||||
|
||||
this.keyboardInput.registerKey(keys.a, 'moveLeft', 'stop', 'moveLeft');
|
||||
this.keyboardInput.registerKey(keys.left, 'moveLeft', 'stop', 'moveLeft');
|
||||
|
|
@ -40,53 +40,53 @@ define(["Game/Core/Control/InputController", "Game/Client/Control/KeyboardInput"
|
|||
this.keyboardInput.registerKey(keys.down, 'activateShift', 'activateShift', 'deactivateShift');
|
||||
}
|
||||
|
||||
KeyboardController.prototype.moveLeft = function() {
|
||||
KeyboardController.prototype.moveLeft = function () {
|
||||
this.inputController.moveLeft();
|
||||
this.gameController.sendGameCommand('moveLeft');
|
||||
}
|
||||
|
||||
KeyboardController.prototype.moveRight = function() {
|
||||
KeyboardController.prototype.moveRight = function () {
|
||||
this.inputController.moveRight();
|
||||
this.gameController.sendGameCommand('moveRight');
|
||||
}
|
||||
|
||||
KeyboardController.prototype.stop = function() {
|
||||
KeyboardController.prototype.stop = function () {
|
||||
this.inputController.stop();
|
||||
this.gameController.sendGameCommand('stop');
|
||||
}
|
||||
|
||||
KeyboardController.prototype.jump = function() {
|
||||
KeyboardController.prototype.jump = function () {
|
||||
this.inputController.jump();
|
||||
this.gameController.sendGameCommand('jump');
|
||||
}
|
||||
|
||||
KeyboardController.prototype.jumped = function() {
|
||||
KeyboardController.prototype.jumped = function () {
|
||||
this.inputController.jumped();
|
||||
}
|
||||
|
||||
KeyboardController.prototype.jumping = function() {
|
||||
KeyboardController.prototype.jumping = function () {
|
||||
this.inputController.jumping();
|
||||
}
|
||||
|
||||
KeyboardController.prototype.duck = function() {
|
||||
KeyboardController.prototype.duck = function () {
|
||||
this.inputController.duck();
|
||||
this.gameController.sendGameCommand('duck');
|
||||
}
|
||||
|
||||
KeyboardController.prototype.standUp = function() {
|
||||
KeyboardController.prototype.standUp = function () {
|
||||
this.inputController.standUp();
|
||||
}
|
||||
|
||||
KeyboardController.prototype.activateShift = function() {
|
||||
KeyboardController.prototype.activateShift = function () {
|
||||
this.inputController.activateShift();
|
||||
this.gameController.sendGameCommand('activateShift');
|
||||
}
|
||||
|
||||
KeyboardController.prototype.deactivateShift = function() {
|
||||
KeyboardController.prototype.deactivateShift = function () {
|
||||
this.inputController.deactivateShift();
|
||||
}
|
||||
|
||||
KeyboardController.prototype.update = function() {
|
||||
KeyboardController.prototype.update = function () {
|
||||
this.keyboardInput.update();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
define(["Game/Client/Control/Key"], function(Key){
|
||||
define(["Game/Client/Control/Key"], function (Key){
|
||||
|
||||
function KeyboardInput (keyboardController) {
|
||||
|
||||
|
|
@ -8,13 +8,13 @@ define(["Game/Client/Control/Key"], function(Key){
|
|||
this.init();
|
||||
}
|
||||
|
||||
KeyboardInput.prototype.init = function() {
|
||||
KeyboardInput.prototype.init = function () {
|
||||
// Using window is ok here because it only runs in the browser
|
||||
window.onkeydown = this._onKeyDown.bind(this);
|
||||
window.onkeyup = this._onKeyUp.bind(this);
|
||||
}
|
||||
|
||||
KeyboardInput.prototype.registerKey = function(keyCode, onKeyDown, onKeyUp, onKeyFrame) {
|
||||
KeyboardInput.prototype.registerKey = function (keyCode, onKeyDown, onKeyUp, onKeyFrame) {
|
||||
var key = new Key();
|
||||
key.setKeyDownFunction(onKeyDown);
|
||||
key.setKeyUpFunction(onKeyUp);
|
||||
|
|
@ -22,11 +22,11 @@ define(["Game/Client/Control/Key"], function(Key){
|
|||
this._registry[keyCode] = key;
|
||||
}
|
||||
|
||||
KeyboardInput.prototype._getKeyByKeyCode = function(keyCode) {
|
||||
KeyboardInput.prototype._getKeyByKeyCode = function (keyCode) {
|
||||
return this._registry[keyCode];
|
||||
}
|
||||
|
||||
KeyboardInput.prototype._onKeyDown = function(e) {
|
||||
KeyboardInput.prototype._onKeyDown = function (e) {
|
||||
var key = this._getKeyByKeyCode(e.keyCode);
|
||||
if (key && key.getActive() == false) {
|
||||
key.setActivityUpdateStatus(true);
|
||||
|
|
@ -34,7 +34,7 @@ define(["Game/Client/Control/Key"], function(Key){
|
|||
}
|
||||
}
|
||||
|
||||
KeyboardInput.prototype._onKeyUp = function(e) {
|
||||
KeyboardInput.prototype._onKeyUp = function (e) {
|
||||
var key = this._getKeyByKeyCode(e.keyCode);
|
||||
if (key != null) {
|
||||
key.setActivityUpdateStatus(false);
|
||||
|
|
@ -42,7 +42,7 @@ define(["Game/Client/Control/Key"], function(Key){
|
|||
}
|
||||
}
|
||||
|
||||
KeyboardInput.prototype.update = function() {
|
||||
KeyboardInput.prototype.update = function () {
|
||||
var callback = null;
|
||||
var self = this;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ define([
|
|||
"Lib/Utilities/RequestAnimFrame"
|
||||
],
|
||||
|
||||
function(Parent, PhysicsEngine, ViewController, KeyboardController, NotificationCenter, requestAnimFrame) {
|
||||
function (Parent, PhysicsEngine, ViewController, KeyboardController, NotificationCenter, requestAnimFrame) {
|
||||
|
||||
function GameController () {
|
||||
this.viewController = new ViewController();
|
||||
|
|
@ -25,11 +25,11 @@ function(Parent, PhysicsEngine, ViewController, KeyboardController, Notification
|
|||
GameController.prototype = Object.create(Parent.prototype);
|
||||
|
||||
/*
|
||||
GameController.prototype.getMe = function() {
|
||||
GameController.prototype.getMe = function () {
|
||||
return this.me;
|
||||
}
|
||||
|
||||
GameController.prototype.update = function() {
|
||||
GameController.prototype.update = function () {
|
||||
|
||||
requestAnimFrame(this.update.bind(this));
|
||||
|
||||
|
|
@ -42,13 +42,13 @@ function(Parent, PhysicsEngine, ViewController, KeyboardController, Notification
|
|||
}
|
||||
}
|
||||
|
||||
GameController.prototype.meJoined = function(user) {
|
||||
GameController.prototype.meJoined = function (user) {
|
||||
this.me = this.userJoined(user);
|
||||
|
||||
this.keyboardController = new KeyboardController(this.me, this);
|
||||
}
|
||||
|
||||
GameController.prototype.processGameCommand = function(command, options) {
|
||||
GameController.prototype.processGameCommand = function (command, options) {
|
||||
|
||||
if (command == "worldUpdate") {
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ define([
|
|||
"Game/Client/GameController"
|
||||
],
|
||||
|
||||
function(ProtocolHelper, GameController) {
|
||||
function (ProtocolHelper, GameController) {
|
||||
|
||||
function Networker(socketLink) {
|
||||
this.socketLink = socketLink;
|
||||
|
|
@ -12,41 +12,41 @@ function(ProtocolHelper, GameController) {
|
|||
this.init();
|
||||
}
|
||||
|
||||
Networker.prototype.init = function() {
|
||||
Networker.prototype.init = function () {
|
||||
|
||||
var self = this;
|
||||
|
||||
this.socketLink.on('connect', function() {
|
||||
this.socketLink.on('connect', function () {
|
||||
self.onConnect();
|
||||
});
|
||||
/*
|
||||
this.socketLink.on('message', function(message) {
|
||||
this.socketLink.on('message', function (message) {
|
||||
self.onMessage(message);
|
||||
});
|
||||
*/
|
||||
this.socketLink.on('disconnect', function() {
|
||||
this.socketLink.on('disconnect', function () {
|
||||
self.onDisconnect();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Networker.prototype.onConnect = function() {
|
||||
Networker.prototype.onConnect = function () {
|
||||
console.log('connected.')
|
||||
this.join('dungeon');
|
||||
}
|
||||
|
||||
Networker.prototype.onDisconnect = function() {
|
||||
Networker.prototype.onDisconnect = function () {
|
||||
if(this.gameController) this.gameController.destruct();
|
||||
this.gameController = null;
|
||||
console.log('disconnected. game destroyed. no auto-reconnect');
|
||||
}
|
||||
|
||||
Networker.prototype.join = function(channelName){
|
||||
Networker.prototype.join = function (channelName){
|
||||
this.sendCommand('join', channelName);
|
||||
}
|
||||
|
||||
|
||||
Networker.prototype.onJoinSuccess = function(options) {
|
||||
Networker.prototype.onJoinSuccess = function (options) {
|
||||
this.gameController = new GameController(options.id);
|
||||
this.gameController.loadLevel("default.json");
|
||||
/*
|
||||
|
|
@ -60,35 +60,35 @@ function(ProtocolHelper, GameController) {
|
|||
*/
|
||||
}
|
||||
|
||||
Networker.prototype.sendCommand = function(command, options) {
|
||||
Networker.prototype.sendCommand = function (command, options) {
|
||||
var message = ProtocolHelper.encodeCommand(command, options);
|
||||
this.socketLink.send(message);
|
||||
}
|
||||
|
||||
/*
|
||||
Networker.prototype.onMessage = function(message) {
|
||||
Networker.prototype.onMessage = function (message) {
|
||||
var self = this;
|
||||
|
||||
ProtocolHelper.runCommands(message, function(command, options) {
|
||||
ProtocolHelper.runCommands(message, function (command, options) {
|
||||
self.processControlCommand(command, options);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Networker.prototype.onUserJoined = function(userId) {
|
||||
Networker.prototype.onUserJoined = function (userId) {
|
||||
this.gameController.userJoined(userId);
|
||||
console.log("User " + userId + " joined");
|
||||
}
|
||||
|
||||
Networker.prototype.sendGameCommand = function(command, options) {
|
||||
Networker.prototype.sendGameCommand = function (command, options) {
|
||||
this.sendCommand('gameCommand', ProtocolHelper.assemble(command, options));
|
||||
}
|
||||
|
||||
Networker.prototype.onUserLeft = function(userId) {
|
||||
Networker.prototype.onUserLeft = function (userId) {
|
||||
this.gameController.userLeft(userId);
|
||||
}
|
||||
|
||||
Networker.prototype.processControlCommand = function(command, options) {
|
||||
Networker.prototype.processControlCommand = function (command, options) {
|
||||
switch(command) {
|
||||
case 'joinSuccess':
|
||||
this.onJoinSuccess(options);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ define([
|
|||
"Lib/Vendor/Box2D"
|
||||
],
|
||||
|
||||
function(Parent, Settings, DomController, Box2D) {
|
||||
function (Parent, Settings, DomController, Box2D) {
|
||||
|
||||
function Engine () {
|
||||
Parent.call(this);
|
||||
|
|
@ -15,7 +15,7 @@ function(Parent, Settings, DomController, Box2D) {
|
|||
}
|
||||
}
|
||||
|
||||
Engine.prototype.setupDebugDraw = function() {
|
||||
Engine.prototype.setupDebugDraw = function () {
|
||||
//var debugSprite = Settings.DEBUG_DRAW_CANVAS_SPRITE;
|
||||
var debugSprite = DomController.getDebugCanvas().getContext("2d");
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ function(Parent, Settings, DomController, Box2D) {
|
|||
}
|
||||
|
||||
|
||||
Engine.prototype.update = function() {
|
||||
Engine.prototype.update = function () {
|
||||
Parent.prototype.update.call(this);
|
||||
|
||||
this.world.DrawDebugData();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
define(['Lib/Vendor/Three', 'Game/Config/Settings'], function(Three, Settings) {
|
||||
define(['Lib/Vendor/Three', 'Game/Config/Settings'], function (Three, Settings) {
|
||||
|
||||
function CameraController(isOrthographic) {
|
||||
|
||||
|
|
@ -31,17 +31,17 @@ define(['Lib/Vendor/Three', 'Game/Config/Settings'], function(Three, Settings) {
|
|||
this.camera.position.z = 481;
|
||||
}
|
||||
|
||||
CameraController.prototype.getCamera = function(){
|
||||
CameraController.prototype.getCamera = function (){
|
||||
return this.camera;
|
||||
}
|
||||
|
||||
CameraController.prototype.setPosition = function(x, y){
|
||||
CameraController.prototype.setPosition = function (x, y){
|
||||
this.camera.position.x = x;
|
||||
this.camera.position.y = y;
|
||||
}
|
||||
|
||||
|
||||
CameraController.prototype.setZoom = function(z){
|
||||
CameraController.prototype.setZoom = function (z){
|
||||
this.camera.position.z = z;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
define(['Game/Config/Settings'], function(Settings) {
|
||||
define(['Game/Config/Settings'], function (Settings) {
|
||||
|
||||
var DomController = {
|
||||
canvas: null,
|
||||
debugCanvas: null
|
||||
};
|
||||
|
||||
DomController.getCanvasContainer = function(){
|
||||
DomController.getCanvasContainer = function (){
|
||||
var container = document.getElementById(Settings.CANVAS_DOM_ID);
|
||||
|
||||
if(container) {
|
||||
|
|
@ -15,11 +15,11 @@ define(['Game/Config/Settings'], function(Settings) {
|
|||
}
|
||||
}
|
||||
|
||||
DomController.getCanvas = function(){
|
||||
DomController.getCanvas = function (){
|
||||
return DomController.canvas;
|
||||
}
|
||||
|
||||
DomController.setCanvas = function(canvas){
|
||||
DomController.setCanvas = function (canvas){
|
||||
|
||||
var container = DomController.getCanvasContainer();
|
||||
if(DomController.canvas){
|
||||
|
|
@ -30,11 +30,11 @@ define(['Game/Config/Settings'], function(Settings) {
|
|||
container.appendChild(canvas);
|
||||
}
|
||||
|
||||
DomController.getDebugCanvas = function(){
|
||||
DomController.getDebugCanvas = function (){
|
||||
return DomController.debugCanvas;
|
||||
}
|
||||
|
||||
DomController.createDebugCanvas = function(){
|
||||
DomController.createDebugCanvas = function (){
|
||||
|
||||
var container = DomController.getCanvasContainer();
|
||||
if(DomController.debugCanvas){
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ var requires = [
|
|||
"Game/Client/View/CameraController"
|
||||
];
|
||||
|
||||
define(requires, function(DomController, Three, Settings, CameraController){
|
||||
define(requires, function (DomController, Three, Settings, CameraController){
|
||||
|
||||
function ViewController(){
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ define(requires, function(DomController, Three, Settings, CameraController){
|
|||
}
|
||||
}
|
||||
|
||||
ViewController.prototype.init = function(){
|
||||
ViewController.prototype.init = function (){
|
||||
|
||||
var self = this;
|
||||
|
||||
|
|
@ -61,12 +61,12 @@ define(requires, function(DomController, Three, Settings, CameraController){
|
|||
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.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);
|
||||
});
|
||||
*/
|
||||
|
|
@ -74,7 +74,7 @@ define(requires, function(DomController, Three, Settings, CameraController){
|
|||
//this.animate(this);
|
||||
}
|
||||
|
||||
ViewController.prototype.update = function() {
|
||||
ViewController.prototype.update = function () {
|
||||
|
||||
if(this.mesh) {
|
||||
this.mesh.rotation.z += .01;
|
||||
|
|
@ -86,14 +86,14 @@ define(requires, function(DomController, Three, Settings, CameraController){
|
|||
this.render();
|
||||
}
|
||||
|
||||
ViewController.prototype.render = function() {
|
||||
ViewController.prototype.render = function () {
|
||||
|
||||
this.renderer.render(this.scene, this.cameraController.getCamera());
|
||||
}
|
||||
|
||||
ViewController.prototype.createMesh = function(width, height, x, y, imgPath, callback) {
|
||||
ViewController.prototype.createMesh = function (width, height, x, y, imgPath, callback) {
|
||||
var textureImg = new Image();
|
||||
textureImg.onload = function(){
|
||||
textureImg.onload = function (){
|
||||
var material = new Three.MeshLambertMaterial({
|
||||
map: Three.ImageUtils.loadTexture(imgPath)
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue