mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed debug view and ragdoll start positioning
This commit is contained in:
parent
b6d979fe7c
commit
16826b174a
12 changed files with 135 additions and 73 deletions
|
|
@ -55,7 +55,9 @@ function (Parent, Nc) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Player.prototype.suicide = function() {
|
Player.prototype.suicide = function() {
|
||||||
|
if(this.isSpawned()) {
|
||||||
this.addDamage(100, this, null);
|
this.addDamage(100, this, null);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Player.prototype.addDamage = function(damage, enemy, byItem) {
|
Player.prototype.addDamage = function(damage, enemy, byItem) {
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,11 @@ define([
|
||||||
"Game/Client/Me",
|
"Game/Client/Me",
|
||||||
"Game/Client/AudioPlayer",
|
"Game/Client/AudioPlayer",
|
||||||
"Game/Client/PointerLockManager",
|
"Game/Client/PointerLockManager",
|
||||||
"Lib/Utilities/Assert"
|
"Lib/Utilities/Assert",
|
||||||
|
"Lib/Utilities/Exception"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, requestAnimFrame, Settings, GameObject, Doll, DomController, ProtocolHelper, Me, AudioPlayer, PointerLockManager, Assert) {
|
function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, requestAnimFrame, Settings, GameObject, Doll, DomController, ProtocolHelper, Me, AudioPlayer, PointerLockManager, Assert, Exception) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -88,7 +89,11 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, reque
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!alreadyExists) {
|
if(!alreadyExists) {
|
||||||
|
// When creating from synchronization we need to bring it into level format (px)
|
||||||
|
itemDef.options.x *= Settings.RATIO;
|
||||||
|
itemDef.options.y *= Settings.RATIO;
|
||||||
this.level.createItem(itemDef.uid, itemDef.options);
|
this.level.createItem(itemDef.uid, itemDef.options);
|
||||||
|
console.log("Creating runtime Item: ", itemDef.options.name, itemDef.uid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -180,6 +185,9 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, reque
|
||||||
|
|
||||||
GameController.prototype.onUpdateStats = function(options) {
|
GameController.prototype.onUpdateStats = function(options) {
|
||||||
var player = this.players[options.playerId];
|
var player = this.players[options.playerId];
|
||||||
|
if(!player) {
|
||||||
|
throw new Exception("No player with id: " + options.playerId);
|
||||||
|
}
|
||||||
player.setStats(options.stats);
|
player.setStats(options.stats);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ define([
|
||||||
"Game/Client/View/Pixi/Layers/Debug"
|
"Game/Client/View/Pixi/Layers/Debug"
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, DebugLayer) {
|
function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, debugLayer) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -25,9 +25,11 @@ function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, DebugLayer) {
|
||||||
Engine.prototype.onToggleDebugMode = function(debugMode) {
|
Engine.prototype.onToggleDebugMode = function(debugMode) {
|
||||||
this.debugMode = debugMode;
|
this.debugMode = debugMode;
|
||||||
|
|
||||||
if(this.debugMode && !this.debugDraw) {
|
if(!this.debugDraw) {
|
||||||
this.setupDebugDraw();
|
this.setupDebugDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugLayer.container.visible = this.debugMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.setupDebugDraw = function () {
|
Engine.prototype.setupDebugDraw = function () {
|
||||||
|
|
@ -35,7 +37,7 @@ function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, DebugLayer) {
|
||||||
// set debug draw
|
// set debug draw
|
||||||
this.debugDraw = new DebugDraw();
|
this.debugDraw = new DebugDraw();
|
||||||
|
|
||||||
this.debugDraw.SetSprite(DebugLayer.graphics);
|
this.debugDraw.SetSprite(debugLayer.graphics);
|
||||||
this.debugDraw.SetDrawScale(Settings.RATIO);
|
this.debugDraw.SetDrawScale(Settings.RATIO);
|
||||||
this.debugDraw.SetFillAlpha(0.5);
|
this.debugDraw.SetFillAlpha(0.5);
|
||||||
this.debugDraw.SetLineThickness(1.0);
|
this.debugDraw.SetLineThickness(1.0);
|
||||||
|
|
@ -51,7 +53,7 @@ function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, DebugLayer) {
|
||||||
);
|
);
|
||||||
|
|
||||||
this.world.SetDebugDraw(this.debugDraw);
|
this.world.SetDebugDraw(this.debugDraw);
|
||||||
}
|
};
|
||||||
|
|
||||||
Engine.prototype.update = function () {
|
Engine.prototype.update = function () {
|
||||||
Parent.prototype.update.call(this);
|
Parent.prototype.update.call(this);
|
||||||
|
|
@ -59,7 +61,7 @@ function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, DebugLayer) {
|
||||||
if(this.debugMode) {
|
if(this.debugMode) {
|
||||||
this.world.DrawDebugData();
|
this.world.DrawDebugData();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return Engine;
|
return Engine;
|
||||||
});
|
});
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
define([
|
define([
|
||||||
'Game/Config/Settings',
|
"Game/Config/Settings",
|
||||||
'Lib/Utilities/NotificationCenter',
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Lib/Vendor/Screenfull",
|
"Lib/Vendor/Screenfull",
|
||||||
"Game/Client/View/Graph",
|
"Game/Client/View/Graph",
|
||||||
"Game/Client/PointerLockManager"
|
"Game/Client/PointerLockManager"
|
||||||
|
|
@ -36,7 +36,7 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
|
||||||
button.innerHTML = "Menu";
|
button.innerHTML = "Menu";
|
||||||
button.onclick = function() {
|
button.onclick = function() {
|
||||||
window.location.href="/";
|
window.location.href="/";
|
||||||
}
|
};
|
||||||
li.appendChild(button);
|
li.appendChild(button);
|
||||||
this.devToolsContainer.appendChild(li);
|
this.devToolsContainer.appendChild(li);
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
|
||||||
scaleStartValue: 0,
|
scaleStartValue: 0,
|
||||||
scaleStepWidth: 0,
|
scaleStepWidth: 0,
|
||||||
scaleSteps: 0
|
scaleSteps: 0
|
||||||
})
|
});
|
||||||
|
|
||||||
// create Ping: container
|
// create Ping: container
|
||||||
li = document.createElement("li");
|
li = document.createElement("li");
|
||||||
|
|
@ -114,7 +114,7 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
|
||||||
checkbox.type = "checkbox";
|
checkbox.type = "checkbox";
|
||||||
checkbox.onclick = function(e) {
|
checkbox.onclick = function(e) {
|
||||||
Nc.trigger(Nc.ns.client.view.debugMode.toggle, e.target.checked);
|
Nc.trigger(Nc.ns.client.view.debugMode.toggle, e.target.checked);
|
||||||
}
|
};
|
||||||
label.appendChild(checkbox);
|
label.appendChild(checkbox);
|
||||||
label.appendChild(document.createTextNode("Debug"));
|
label.appendChild(document.createTextNode("Debug"));
|
||||||
li.appendChild(label);
|
li.appendChild(label);
|
||||||
|
|
@ -123,7 +123,7 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
|
||||||
|
|
||||||
// create Fullscreen
|
// create Fullscreen
|
||||||
li = document.createElement("li");
|
li = document.createElement("li");
|
||||||
li.id = "fullscreen"
|
li.id = "fullscreen";
|
||||||
button = document.createElement("button");
|
button = document.createElement("button");
|
||||||
button.innerHTML = "Fullscreen";
|
button.innerHTML = "Fullscreen";
|
||||||
button.onclick = function() {
|
button.onclick = function() {
|
||||||
|
|
@ -131,7 +131,7 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
|
||||||
PointerLockManager.request();
|
PointerLockManager.request();
|
||||||
Screenfull.request(self.canvas);
|
Screenfull.request(self.canvas);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
li.appendChild(button);
|
li.appendChild(button);
|
||||||
this.devToolsContainer.appendChild(li);
|
this.devToolsContainer.appendChild(li);
|
||||||
|
|
||||||
|
|
@ -139,13 +139,12 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
|
||||||
// FIXME : isn't this a weird place for this?
|
// FIXME : isn't this a weird place for this?
|
||||||
window.onresize = function() {
|
window.onresize = function() {
|
||||||
Nc.trigger(Nc.ns.client.view.display.change);
|
Nc.trigger(Nc.ns.client.view.display.change);
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
DomController.prototype.setNick = function (nick) {
|
DomController.prototype.setNick = function (nick) {
|
||||||
this.nickContainer.innerHTML = nick
|
this.nickContainer.innerHTML = nick;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
DomController.prototype.fpsStep = function() {
|
DomController.prototype.fpsStep = function() {
|
||||||
this.fpsGraph.step();
|
this.fpsGraph.step();
|
||||||
|
|
@ -164,15 +163,15 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
|
||||||
} else {
|
} else {
|
||||||
throw 'Canvas Container missing: #' + Settings.CANVAS_DOM_ID;
|
throw 'Canvas Container missing: #' + Settings.CANVAS_DOM_ID;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
DomController.prototype.getCanvas = function () {
|
DomController.prototype.getCanvas = function () {
|
||||||
return this.canvas;
|
return this.canvas;
|
||||||
}
|
};
|
||||||
|
|
||||||
DomController.prototype.initCanvas = function (canvas) {
|
DomController.prototype.initCanvas = function (canvas) {
|
||||||
Nc.trigger(Nc.ns.client.view.display.change, Screenfull.isFullscreen);
|
Nc.trigger(Nc.ns.client.view.display.change, Screenfull.isFullscreen);
|
||||||
}
|
};
|
||||||
|
|
||||||
DomController.prototype.setConnected = function(connected) {
|
DomController.prototype.setConnected = function(connected) {
|
||||||
if(connected) {
|
if(connected) {
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
define([
|
define([
|
||||||
"Game/Client/View/Pixi/Layer",
|
"Game/Client/View/Pixi/Layer",
|
||||||
"Lib/Vendor/Pixi",
|
"Lib/Vendor/Pixi",
|
||||||
"Game/Config/Settings",
|
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
function (Parent, PIXI, Settings) {
|
function (Parent, PIXI) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function Debug() {
|
function Debug() {
|
||||||
Parent.call(this, "debug", 0);
|
Parent.call(this, "debug", 0.00000001);
|
||||||
|
|
||||||
|
|
||||||
this.graphics = new PIXI.Graphics();
|
this.graphics = new PIXI.Graphics();
|
||||||
|
|
@ -20,14 +18,11 @@ function (Parent, PIXI, Settings) {
|
||||||
Debug.prototype = Object.create(Parent.prototype);
|
Debug.prototype = Object.create(Parent.prototype);
|
||||||
|
|
||||||
Debug.prototype.render = function(centerPosition, zoom) {
|
Debug.prototype.render = function(centerPosition, zoom) {
|
||||||
|
|
||||||
Parent.prototype.render.call(this, centerPosition, zoom);
|
Parent.prototype.render.call(this, centerPosition, zoom);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.container.x -= 300 * zoom;
|
this.container.x -= 300 * zoom;
|
||||||
this.container.y -= 200 * zoom;
|
this.container.y -= 200 * zoom;
|
||||||
}
|
};
|
||||||
|
|
||||||
return new Debug();
|
return new Debug();
|
||||||
});
|
});
|
||||||
|
|
@ -28,7 +28,7 @@ function () {
|
||||||
MAPS_PATH: "static/maps/tiled/",
|
MAPS_PATH: "static/maps/tiled/",
|
||||||
AUDIO_PATH: "static/sounds/",
|
AUDIO_PATH: "static/sounds/",
|
||||||
CHANNEL_RECORDING_PATH: "recordings/",
|
CHANNEL_RECORDING_PATH: "recordings/",
|
||||||
CHANNEL_PLAY_RECORDING: false, //"Quickstart-2015-03-15T19:00:28.545Z-debug_residence_stones.log",
|
CHANNEL_PLAY_RECORDING: false, //"Varberg-2015-03-15T23:10:29.316Z-stones.log",
|
||||||
|
|
||||||
RATIO: 21, //35
|
RATIO: 21, //35
|
||||||
// original tile size is 25 but we want it to resize to 20
|
// original tile size is 25 but we want it to resize to 20
|
||||||
|
|
@ -52,7 +52,7 @@ function () {
|
||||||
RESPAWN_TIME: 5,
|
RESPAWN_TIME: 5,
|
||||||
HEALTH_DISPLAY_TIME: 2,
|
HEALTH_DISPLAY_TIME: 2,
|
||||||
CRITICAL_HEALTH_THRESHOLD: 0.3,
|
CRITICAL_HEALTH_THRESHOLD: 0.3,
|
||||||
RAGDOLL_DESTRUCTION_TIME: 20000,
|
RAGDOLL_DESTRUCTION_TIME: 10,
|
||||||
VIEWPORT_SPEED_FACTOR: 640,
|
VIEWPORT_SPEED_FACTOR: 640,
|
||||||
VIEWPORT_LOOK_AHEAD: 0.1,
|
VIEWPORT_LOOK_AHEAD: 0.1,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,10 +102,10 @@ function (Parent, Box2D, Settings, Nc, Assert, Options, ItemSettings) {
|
||||||
//this.createSensor();
|
//this.createSensor();
|
||||||
|
|
||||||
this.limbs = {};
|
this.limbs = {};
|
||||||
|
|
||||||
this.addHead();
|
this.addHead();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.addLimb(
|
this.addLimb(
|
||||||
"upperLeftLeg",
|
"upperLeftLeg",
|
||||||
this.body,
|
this.body,
|
||||||
|
|
@ -137,7 +137,6 @@ function (Parent, Box2D, Settings, Nc, Assert, Options, ItemSettings) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.addLimb(
|
this.addLimb(
|
||||||
"upperLeftArm",
|
"upperLeftArm",
|
||||||
this.body,
|
this.body,
|
||||||
|
|
@ -165,6 +164,7 @@ function (Parent, Box2D, Settings, Nc, Assert, Options, ItemSettings) {
|
||||||
0,
|
0,
|
||||||
options.limbs.upperRightArm.height / 2
|
options.limbs.upperRightArm.height / 2
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RagDoll.prototype = Object.create(Parent.prototype);
|
RagDoll.prototype = Object.create(Parent.prototype);
|
||||||
|
|
@ -185,6 +185,8 @@ function (Parent, Box2D, Settings, Nc, Assert, Options, ItemSettings) {
|
||||||
var bodyDef = Parent.prototype.getBodyDef.call(this);
|
var bodyDef = Parent.prototype.getBodyDef.call(this);
|
||||||
bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING;
|
bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING;
|
||||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||||
|
bodyDef.position.y -= this.options.height / 2 / Settings.RATIO; // position it on top of ground
|
||||||
|
|
||||||
return bodyDef;
|
return bodyDef;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -235,7 +237,7 @@ function (Parent, Box2D, Settings, Nc, Assert, Options, ItemSettings) {
|
||||||
Assert.number(this.options.limbs.head.width);
|
Assert.number(this.options.limbs.head.width);
|
||||||
|
|
||||||
var x = this.options.x + this.options.limbs.head.x,
|
var x = this.options.x + this.options.limbs.head.x,
|
||||||
y = this.options.y + this.options.limbs.head.y;
|
y = this.options.y + this.options.limbs.head.y - this.options.height / 2; // position it on top of ground;
|
||||||
|
|
||||||
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
||||||
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
|
||||||
|
|
@ -286,7 +288,7 @@ function (Parent, Box2D, Settings, Nc, Assert, Options, ItemSettings) {
|
||||||
Assert.number(this.options.limbs[name].width, this.options.limbs[name].height);
|
Assert.number(this.options.limbs[name].width, this.options.limbs[name].height);
|
||||||
|
|
||||||
var x = this.options.x + this.options.limbs[name].x,
|
var x = this.options.x + this.options.limbs[name].x,
|
||||||
y = this.options.y + this.options.limbs[name].y;
|
y = this.options.y + this.options.limbs[name].y - this.options.height / 2; // position it on top of ground;;
|
||||||
|
|
||||||
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
||||||
bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING;
|
bodyDef.linearDamping = Settings.PLAYER_LINEAR_DAMPING;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ function (Parent, Box2D, Settings, Assert) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Skateboard.prototype.addWheel = function(x, y) {
|
Skateboard.prototype.addWheel = function(x, y) {
|
||||||
|
|
||||||
Assert.number(x, y);
|
Assert.number(x, y);
|
||||||
|
|
||||||
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
var bodyDef = new Box2D.Dynamics.b2BodyDef();
|
||||||
|
|
@ -71,15 +70,20 @@ function (Parent, Box2D, Settings, Assert) {
|
||||||
fixtureDef.density = density;
|
fixtureDef.density = density;
|
||||||
fixtureDef.shape = wheelShape;
|
fixtureDef.shape = wheelShape;
|
||||||
fixtureDef.isSensor = false;
|
fixtureDef.isSensor = false;
|
||||||
|
fixtureDef.friction = 0;
|
||||||
|
|
||||||
var wheelBody = this.body.GetWorld().CreateBody(bodyDef);
|
var wheelBody = this.body.GetWorld().CreateBody(bodyDef);
|
||||||
wheelBody.CreateFixture(fixtureDef);
|
wheelBody.CreateFixture(fixtureDef);
|
||||||
|
|
||||||
var revoluteJointDef = new Box2D.Dynamics.Joints.b2RevoluteJointDef();
|
//var revoluteJointDef = new Box2D.Dynamics.Joints.b2RevoluteJointDef();
|
||||||
revoluteJointDef.enableMotor = false;
|
var revoluteJointDef = new Box2D.Dynamics.Joints.b2WeldJointDef();
|
||||||
|
//revoluteJointDef.enableMotor = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
revoluteJointDef.Initialize(this.body, wheelBody, wheelBody.GetWorldCenter());
|
revoluteJointDef.Initialize(this.body, wheelBody, wheelBody.GetWorldCenter());
|
||||||
this.body.GetWorld().CreateJoint(revoluteJointDef);
|
var j = this.body.GetWorld().CreateJoint(revoluteJointDef);
|
||||||
|
|
||||||
|
|
||||||
// FIXME this means, that we will have bodies in the world, which must not be
|
// FIXME this means, that we will have bodies in the world, which must not be
|
||||||
// updated (wheels) because they are always connected to a body which will be updated.
|
// updated (wheels) because they are always connected to a body which will be updated.
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,13 @@ define([
|
||||||
|
|
||||||
Level.prototype.load = function (uid) {
|
Level.prototype.load = function (uid) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var path = Settings.MAPS_PATH + uid + ".json"
|
var path = Settings.MAPS_PATH + uid + ".json";
|
||||||
this.loadLevelDataFromPath(path, function (levelData) {
|
this.loadLevelDataFromPath(path, function (levelData) {
|
||||||
self.setup(levelData);
|
self.setup(levelData);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
Level.prototype.setup = function(levelData) {
|
Level.prototype.setup = function(levelData) { // jshint unused:false
|
||||||
this.isLoaded = true;
|
this.isLoaded = true;
|
||||||
Nc.trigger(Nc.ns.core.game.events.level.loaded);
|
Nc.trigger(Nc.ns.core.game.events.level.loaded);
|
||||||
};
|
};
|
||||||
|
|
@ -40,17 +40,17 @@ define([
|
||||||
for (var i = 0; i < options.length; i++) {
|
for (var i = 0; i < options.length; i++) {
|
||||||
var uid = "item-" + i;
|
var uid = "item-" + i;
|
||||||
this.createItem(uid, options[i]);
|
this.createItem(uid, options[i]);
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Level.prototype.createItem = function(uid, options) {
|
Level.prototype.createItem = function(uid, options) {
|
||||||
|
|
||||||
switch(options.type) {
|
switch(options.type) {
|
||||||
//case 'skateboard':
|
//case "skateboard":
|
||||||
// return new Skateboard(this.engine, uid, options);
|
// return new Skateboard(this.engine, uid, options);
|
||||||
case 'ragdoll':
|
case "ragdoll":
|
||||||
return new RagDoll(this.engine, uid, options);
|
return new RagDoll(this.engine, uid, options);
|
||||||
case 'rube':
|
case "rube":
|
||||||
return new Rube(this.engine, uid, options);
|
return new Rube(this.engine, uid, options);
|
||||||
default:
|
default:
|
||||||
return new Item(this.engine, uid, options);
|
return new Item(this.engine, uid, options);
|
||||||
|
|
@ -60,19 +60,19 @@ define([
|
||||||
Level.prototype.createTiles = function(options) {
|
Level.prototype.createTiles = function(options) {
|
||||||
for (var i = 0; i < options.length; i++) {
|
for (var i = 0; i < options.length; i++) {
|
||||||
new Tile(this.engine, "tile-" + i, options[i]);
|
new Tile(this.engine, "tile-" + i, options[i]);
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Level.prototype.createSpawnPoints = function(points) {
|
Level.prototype.createSpawnPoints = function(points) {
|
||||||
this.spawnPoints = points;
|
this.spawnPoints = points;
|
||||||
};
|
};
|
||||||
|
|
||||||
Level.prototype.setupLayer = function(options, behind, referenceId) {
|
Level.prototype.setupLayer = function(options, behind, referenceId) { // jshint unused:false
|
||||||
// will be extended (so far only in client)
|
// will be extended (so far only in client)
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
Level.prototype.createContainer = function(options) {
|
Level.prototype.createContainer = function(options) { // jshint unused:false
|
||||||
// nothing to do here yet, in the future perhaps synchronize day/night graphics
|
// nothing to do here yet, in the future perhaps synchronize day/night graphics
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -90,12 +90,12 @@ define([
|
||||||
return {
|
return {
|
||||||
x: object.x / Settings.TILE_RATIO,
|
x: object.x / Settings.TILE_RATIO,
|
||||||
y: object.y / Settings.TILE_RATIO
|
y: object.y / Settings.TILE_RATIO
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
Level.prototype.destroy = function () {
|
Level.prototype.destroy = function () {
|
||||||
this.isLoaded = false;
|
this.isLoaded = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
return Level;
|
return Level;
|
||||||
});
|
});
|
||||||
|
|
@ -6,13 +6,14 @@ define([
|
||||||
"Lib/Utilities/Options",
|
"Lib/Utilities/Options",
|
||||||
"Lib/Utilities/Exception",
|
"Lib/Utilities/Exception",
|
||||||
"Lib/Utilities/NotificationCenter",
|
"Lib/Utilities/NotificationCenter",
|
||||||
|
"Lib/Utilities/Assert",
|
||||||
"Game/Client/View/Abstract/Layer",
|
"Game/Client/View/Abstract/Layer",
|
||||||
"Game/" + GLOBALS.context + "/Collision/Detector",
|
"Game/" + GLOBALS.context + "/Collision/Detector",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Tile",
|
"Game/" + GLOBALS.context + "/GameObjects/Tile",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
|
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
|
||||||
|
|
||||||
], function (Parent, Settings, ItemSettings, Box2D, Options, Exception, Nc, AbstractLayer, CollisionDetector, Tile, Item, Skateboard) {
|
], function (Parent, Settings, ItemSettings, Box2D, Options, Exception, Nc, Assert, AbstractLayer, CollisionDetector, Tile, Item, Skateboard) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -40,7 +41,7 @@ define([
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!spawnpointsExists) {
|
if (!spawnpointsExists) {
|
||||||
console.warn('No layerMapping for level file layer: ' + layerOptions.name);
|
console.warn("No layerMapping for level file layer: " + layerOptions.name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,7 +50,7 @@ define([
|
||||||
tiles: AbstractLayer.ID.TILE,
|
tiles: AbstractLayer.ID.TILE,
|
||||||
items: AbstractLayer.ID.ITEM,
|
items: AbstractLayer.ID.ITEM,
|
||||||
spawnpoints: AbstractLayer.ID.SPAWN
|
spawnpoints: AbstractLayer.ID.SPAWN
|
||||||
}
|
};
|
||||||
if(mapping[name]) {
|
if(mapping[name]) {
|
||||||
return mapping[name];
|
return mapping[name];
|
||||||
}
|
}
|
||||||
|
|
@ -167,26 +168,15 @@ define([
|
||||||
};
|
};
|
||||||
|
|
||||||
TiledLevel.prototype.gatherOptions = function(tiledObject) {
|
TiledLevel.prototype.gatherOptions = function(tiledObject) {
|
||||||
var options = {};
|
var options = this.getDefaultItemSettingsByName(tiledObject.name);
|
||||||
|
|
||||||
options.name = tiledObject.name;
|
options.name = tiledObject.name;
|
||||||
options.rotation = tiledObject.rotation;
|
options.x = (tiledObject.x + options.width / 2) / Settings.TILE_RATIO;
|
||||||
options.width = tiledObject.width / Settings.TILE_RATIO;
|
|
||||||
options.height = tiledObject.height / Settings.TILE_RATIO;
|
|
||||||
options.x = (tiledObject.x + tiledObject.width / 2) / Settings.TILE_RATIO;
|
|
||||||
options.y = (tiledObject.y + options.height / 2) / Settings.TILE_RATIO;
|
options.y = (tiledObject.y + options.height / 2) / Settings.TILE_RATIO;
|
||||||
|
// FIXME: check RAD vs. DEG for options.rotation = tiledObject.rotation;
|
||||||
if (!options.width) options.width = undefined;
|
|
||||||
if (!options.height) options.height = undefined;
|
|
||||||
|
|
||||||
var defaultOptions = this.getDefaultItemSettingsByName(options.name);
|
|
||||||
|
|
||||||
options = Options.merge(options, defaultOptions);
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TiledLevel.prototype.getDefaultItemSettingsByName = function(name) {
|
TiledLevel.prototype.getDefaultItemSettingsByName = function(name) {
|
||||||
|
|
||||||
if(!name) {
|
if(!name) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
m1426446028547{"recipient":"channel","data":{"addUser":{"id":"7389285181034131943","nickname":"Jeena"}}}
|
m1426446028547{"recipient":"channel","data":{"addUser":{"id":"7389285181034131943","nickname":"Bot1"}}}
|
||||||
m1426446029119{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"clientReady\\\":null}\"}"}
|
m1426446029119{"recipient":"7389285181034131943","data":"{\"gameCommand\":\"{\\\"clientReady\\\":null}\"}"}
|
||||||
w1426446029547{"doll-7389285181034131943":{"p":{"x":26.757009396292265,"y":2.8537988666369247},"a":0,"lv":{"x":0,"y":3.686287386450715e-18},"av":0,"as":"stand","laxy":{"x":0,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":20.68034223796989,"y":14.27172409912905},"a":0.05645956288623199,"lv":{"x":-0.3822032971313994,"y":0.10581586623357915},"av":-0.9131901027366345},"item-4":{"p":{"x":20.210667860242594,"y":14.23713937029844},"a":0.2172662762511257,"lv":{"x":-0.4539838684349691,"y":0.056447865910879066},"av":-0.8171646189887583},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":9.013612698412686,"y":18.087738095238098},"a":0,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.14632479802086,"y":14.27055244283271},"a":-0.030402669209750526,"lv":{"x":0.36764627338079947,"y":0.11541986576858798},"av":0.6858739292935763}}
|
w1426446029547{"doll-7389285181034131943":{"p":{"x":26.757009396292265,"y":2.8537988666369247},"a":0,"lv":{"x":0,"y":3.686287386450715e-18},"av":0,"as":"stand","laxy":{"x":0,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":20.68034223796989,"y":14.27172409912905},"a":0.05645956288623199,"lv":{"x":-0.3822032971313994,"y":0.10581586623357915},"av":-0.9131901027366345},"item-4":{"p":{"x":20.210667860242594,"y":14.23713937029844},"a":0.2172662762511257,"lv":{"x":-0.4539838684349691,"y":0.056447865910879066},"av":-0.8171646189887583},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":9.013612698412686,"y":18.087738095238098},"a":0,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.14632479802086,"y":14.27055244283271},"a":-0.030402669209750526,"lv":{"x":0.36764627338079947,"y":0.11541986576858798},"av":0.6858739292935763}}
|
||||||
w1426446030548{"doll-7389285181034131943":{"p":{"x":26.757009396292265,"y":2.8537988666369247},"a":0,"lv":{"x":0,"y":0},"av":0,"as":"stand","laxy":{"x":0,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":20.676956793943322,"y":14.27693273489722},"a":-0.006893630787064592,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200040618322713,"y":14.276203443653712},"a":-0.0004911852214511643,"lv":{"x":-0.0017410956075321858,"y":8.552005003579723e-7},"av":3.946495907847236e-17},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":9.013612698412686,"y":18.087738095238098},"a":0,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
w1426446030548{"doll-7389285181034131943":{"p":{"x":26.757009396292265,"y":2.8537988666369247},"a":0,"lv":{"x":0,"y":0},"av":0,"as":"stand","laxy":{"x":0,"y":0}},"item-6":{"p":{"x":17.676190476190477,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-5":{"p":{"x":20.676956793943322,"y":14.27693273489722},"a":-0.006893630787064592,"lv":{"x":0,"y":0},"av":0},"item-4":{"p":{"x":20.200040618322713,"y":14.276203443653712},"a":-0.0004911852214511643,"lv":{"x":-0.0017410956075321858,"y":8.552005003579723e-7},"av":3.946495907847236e-17},"item-3":{"p":{"x":22.4,"y":14.277445638095237},"a":0,"lv":{"x":0,"y":0},"av":0},"item-2":{"p":{"x":9.013612698412686,"y":18.087738095238098},"a":0,"lv":{"x":0,"y":0},"av":0},"item-1":{"p":{"x":19.642184126984116,"y":14.278214285714286},"a":0,"lv":{"x":0,"y":0},"av":0},"item-0":{"p":{"x":19.147450032657666,"y":14.276009262801196},"a":0.0025201794161469693,"lv":{"x":0,"y":0},"av":0}}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
"type":"imagelayer",
|
"type":"imagelayer",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":0,
|
"width":0,
|
||||||
"x":121,
|
"x":120,
|
||||||
"y":43
|
"y":43
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -402,6 +402,66 @@
|
||||||
"width":0,
|
"width":0,
|
||||||
"x":286.077500264968,
|
"x":286.077500264968,
|
||||||
"y":59.318656270437
|
"y":59.318656270437
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":0,
|
||||||
|
"id":35,
|
||||||
|
"name":"Skateboard",
|
||||||
|
"properties":
|
||||||
|
{
|
||||||
|
|
||||||
|
},
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":0,
|
||||||
|
"x":1317,
|
||||||
|
"y":458
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":0,
|
||||||
|
"id":36,
|
||||||
|
"name":"Laundry Machine",
|
||||||
|
"properties":
|
||||||
|
{
|
||||||
|
|
||||||
|
},
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":0,
|
||||||
|
"x":557,
|
||||||
|
"y":711
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":0,
|
||||||
|
"id":39,
|
||||||
|
"name":"Laundry Machine",
|
||||||
|
"properties":
|
||||||
|
{
|
||||||
|
|
||||||
|
},
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":0,
|
||||||
|
"x":1557,
|
||||||
|
"y":508
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":0,
|
||||||
|
"id":40,
|
||||||
|
"name":"Laundry Machine",
|
||||||
|
"properties":
|
||||||
|
{
|
||||||
|
|
||||||
|
},
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":0,
|
||||||
|
"x":1457,
|
||||||
|
"y":733
|
||||||
}],
|
}],
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"type":"objectgroup",
|
"type":"objectgroup",
|
||||||
|
|
@ -550,7 +610,7 @@
|
||||||
"x":0,
|
"x":0,
|
||||||
"y":0
|
"y":0
|
||||||
}],
|
}],
|
||||||
"nextobjectid":35,
|
"nextobjectid":41,
|
||||||
"orientation":"orthogonal",
|
"orientation":"orthogonal",
|
||||||
"properties":
|
"properties":
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue