fixed debug view and ragdoll start positioning

This commit is contained in:
Jeena 2015-03-16 01:50:41 +01:00
parent b6d979fe7c
commit 16826b174a
12 changed files with 135 additions and 73 deletions

View file

@ -14,10 +14,11 @@ define([
"Game/Client/Me",
"Game/Client/AudioPlayer",
"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";
@ -88,7 +89,11 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, reque
}
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);
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) {
var player = this.players[options.playerId];
if(!player) {
throw new Exception("No player with id: " + options.playerId);
}
player.setStats(options.stats);
};

View file

@ -8,7 +8,7 @@ define([
"Game/Client/View/Pixi/Layers/Debug"
],
function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, DebugLayer) {
function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, debugLayer) {
"use strict";
@ -25,9 +25,11 @@ function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, DebugLayer) {
Engine.prototype.onToggleDebugMode = function(debugMode) {
this.debugMode = debugMode;
if(this.debugMode && !this.debugDraw) {
if(!this.debugDraw) {
this.setupDebugDraw();
}
debugLayer.container.visible = this.debugMode;
};
Engine.prototype.setupDebugDraw = function () {
@ -35,7 +37,7 @@ function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, DebugLayer) {
// set debug draw
this.debugDraw = new DebugDraw();
this.debugDraw.SetSprite(DebugLayer.graphics);
this.debugDraw.SetSprite(debugLayer.graphics);
this.debugDraw.SetDrawScale(Settings.RATIO);
this.debugDraw.SetFillAlpha(0.5);
this.debugDraw.SetLineThickness(1.0);
@ -51,7 +53,7 @@ function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, DebugLayer) {
);
this.world.SetDebugDraw(this.debugDraw);
}
};
Engine.prototype.update = function () {
Parent.prototype.update.call(this);
@ -59,7 +61,7 @@ function (Parent, Settings, DomController, Box2D, Nc, DebugDraw, DebugLayer) {
if(this.debugMode) {
this.world.DrawDebugData();
}
}
};
return Engine;
});

View file

@ -1,6 +1,6 @@
define([
'Game/Config/Settings',
'Lib/Utilities/NotificationCenter',
"Game/Config/Settings",
"Lib/Utilities/NotificationCenter",
"Lib/Vendor/Screenfull",
"Game/Client/View/Graph",
"Game/Client/PointerLockManager"
@ -36,7 +36,7 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
button.innerHTML = "Menu";
button.onclick = function() {
window.location.href="/";
}
};
li.appendChild(button);
this.devToolsContainer.appendChild(li);
@ -98,7 +98,7 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
scaleStartValue: 0,
scaleStepWidth: 0,
scaleSteps: 0
})
});
// create Ping: container
li = document.createElement("li");
@ -114,7 +114,7 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
checkbox.type = "checkbox";
checkbox.onclick = function(e) {
Nc.trigger(Nc.ns.client.view.debugMode.toggle, e.target.checked);
}
};
label.appendChild(checkbox);
label.appendChild(document.createTextNode("Debug"));
li.appendChild(label);
@ -123,7 +123,7 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
// create Fullscreen
li = document.createElement("li");
li.id = "fullscreen"
li.id = "fullscreen";
button = document.createElement("button");
button.innerHTML = "Fullscreen";
button.onclick = function() {
@ -131,7 +131,7 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
PointerLockManager.request();
Screenfull.request(self.canvas);
}
}
};
li.appendChild(button);
this.devToolsContainer.appendChild(li);
@ -139,13 +139,12 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
// FIXME : isn't this a weird place for this?
window.onresize = function() {
Nc.trigger(Nc.ns.client.view.display.change);
}
};
};
DomController.prototype.setNick = function (nick) {
this.nickContainer.innerHTML = nick
}
this.nickContainer.innerHTML = nick;
};
DomController.prototype.fpsStep = function() {
this.fpsGraph.step();
@ -164,15 +163,15 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
} else {
throw 'Canvas Container missing: #' + Settings.CANVAS_DOM_ID;
}
}
};
DomController.prototype.getCanvas = function () {
return this.canvas;
}
};
DomController.prototype.initCanvas = function (canvas) {
Nc.trigger(Nc.ns.client.view.display.change, Screenfull.isFullscreen);
}
};
DomController.prototype.setConnected = function(connected) {
if(connected) {

View file

@ -1,16 +1,14 @@
define([
"Game/Client/View/Pixi/Layer",
"Lib/Vendor/Pixi",
"Game/Config/Settings",
],
function (Parent, PIXI, Settings) {
function (Parent, PIXI) {
"use strict";
function Debug() {
Parent.call(this, "debug", 0);
Parent.call(this, "debug", 0.00000001);
this.graphics = new PIXI.Graphics();
@ -20,14 +18,11 @@ function (Parent, PIXI, Settings) {
Debug.prototype = Object.create(Parent.prototype);
Debug.prototype.render = function(centerPosition, zoom) {
Parent.prototype.render.call(this, centerPosition, zoom);
this.container.x -= 300 * zoom;
this.container.y -= 200 * zoom;
}
};
return new Debug();
});