Commit 249f7e6e authored by Terence Martin's avatar Terence Martin

Include Question mark debugging key

This adds in the question mark key during debugging mode to dump some
information to the console of the maze entity currently at this maze
position.
parent 05ae4a83
...@@ -115,6 +115,8 @@ ...@@ -115,6 +115,8 @@
<dt>Left Click on a Ball</dt> <dt>Left Click on a Ball</dt>
<dd>Drop ball into the maze</dd> <dd>Drop ball into the maze</dd>
<h3>While in debug/editing mode:</h3> <h3>While in debug/editing mode:</h3>
<dt>?</dt>
<dd>Log info on selected maze cell</dd>
<dt>Left Click on Bonus/Gray Brick</dt> <dt>Left Click on Bonus/Gray Brick</dt>
<dd>Vanish or appear brick</dd> <dd>Vanish or appear brick</dd>
<dt>Left Click on an Arrow</dt> <dt>Left Click on an Arrow</dt>
......
...@@ -1228,6 +1228,38 @@ var nurdz; ...@@ -1228,6 +1228,38 @@ var nurdz;
MazeDebugger.prototype.setDebugCell = function (newCell) { MazeDebugger.prototype.setDebugCell = function (newCell) {
this._contents.setCellAt(this._debugPoint.x, this._debugPoint.y, newCell); this._contents.setCellAt(this._debugPoint.x, this._debugPoint.y, newCell);
}; };
/**
* Log to the console some information on the currently selected debug
* cell in the maze, such as it's class, position, etc.
*/
MazeDebugger.prototype.debugShowContents = function () {
// Do nothing if tracking is turned off.
if (this._debugTracking == false)
return false;
// We always display the maze location no matter what.
console.log("[DEBUG]: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
console.log("[DEBUG]: Selected maze location: " + this._debugPoint.toString());
// Get the cell; if it's empty, say so and leave.
var cell = this.getDebugCell();
if (cell == null) {
console.log("[DEBUG]: Maze reports empty at this location");
return true;
}
if (cell.pool != null) {
var isAlive = cell.pool.liveEntities.indexOf(cell) != -1;
console.log("[DEBUG]: Entity is in pool (" + (isAlive ? "alive" : "dead") + ")");
}
else
console.log("[DEBUG]: No assigned actor pool");
// Display some core information about this entity
console.log("[DEBUG]: Entity type: " + cell.name + " (id=" + cell.properties.id + ")");
console.log("[DEBUG]: Maze position: " + cell.mapPosition.toString());
console.log("[DEBUG]: Screen position: " + cell.position.toString());
console.log("[DEBUG]: Current animation: " + cell.animations.current);
console.log("[DEBUG]: Current sprite: " + cell["_sprite"]);
console.log("[DEBUG]: Object: ", cell);
return true;
};
/** /**
* Remove the contents of an existing cell from the maze, returning the * Remove the contents of an existing cell from the maze, returning the
* object back into its pool. * object back into its pool.
...@@ -4592,6 +4624,10 @@ var nurdz; ...@@ -4592,6 +4624,10 @@ var nurdz;
return true; return true;
// The question mark key; this is not in ts-game-engine yet. // The question mark key; this is not in ts-game-engine yet.
case 191: case 191:
// If we're in debugging mode, don't handle the key here and
// let the debug code handle it instead.
if (this._maze.debugger.debugTracking)
return false;
// Get the AI to select a ball. If one was selected, jump // Get the AI to select a ball. If one was selected, jump
// the player to that position, turn to face it, and push. // the player to that position, turn to face it, and push.
// The push might not work if we're not already facing down, // The push might not work if we're not already facing down,
...@@ -4687,6 +4723,9 @@ var nurdz; ...@@ -4687,6 +4723,9 @@ var nurdz;
// no new maze is generated first. // no new maze is generated first.
case game.KeyCodes.KEY_W: case game.KeyCodes.KEY_W:
return this._debugger.debugWipeMaze(); return this._debugger.debugWipeMaze();
// The question mark key; this is not in ts-game-engine yet.
case 191:
return this._debugger.debugShowContents();
// For debugging purposes, this key swaps to human balls // For debugging purposes, this key swaps to human balls
case game.KeyCodes.KEY_Z: case game.KeyCodes.KEY_Z:
console.log("human balls"); console.log("human balls");
......
...@@ -158,6 +158,48 @@ module nurdz.game ...@@ -158,6 +158,48 @@ module nurdz.game
this._contents.setCellAt (this._debugPoint.x, this._debugPoint.y, newCell); this._contents.setCellAt (this._debugPoint.x, this._debugPoint.y, newCell);
} }
/**
* Log to the console some information on the currently selected debug
* cell in the maze, such as it's class, position, etc.
*/
debugShowContents () : boolean
{
// Do nothing if tracking is turned off.
if (this._debugTracking == false)
return false;
// We always display the maze location no matter what.
console.log ("[DEBUG]: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
console.log ("[DEBUG]: Selected maze location: " + this._debugPoint.toString ());
// Get the cell; if it's empty, say so and leave.
let cell = this.getDebugCell ();
if (cell == null)
{
console.log ("[DEBUG]: Maze reports empty at this location");
return true;
}
if (cell.pool != null)
{
let isAlive = cell.pool.liveEntities.indexOf (cell) != -1;
console.log ("[DEBUG]: Entity is in pool (" + (isAlive ? "alive" : "dead") + ")");
}
else
console.log ("[DEBUG]: No assigned actor pool");
// Display some core information about this entity
console.log ("[DEBUG]: Entity type: " + cell.name + " (id=" + cell.properties.id + ")");
console.log ("[DEBUG]: Maze position: " + cell.mapPosition.toString ());
console.log ("[DEBUG]: Screen position: " + cell.position.toString ());
console.log ("[DEBUG]: Current animation: " + cell.animations.current);
console.log ("[DEBUG]: Current sprite: " + cell["_sprite"]);
console.log ("[DEBUG]: Object: ", cell);
return true;
}
/** /**
* Remove the contents of an existing cell from the maze, returning the * Remove the contents of an existing cell from the maze, returning the
* object back into its pool. * object back into its pool.
......
...@@ -238,6 +238,11 @@ module nurdz.game ...@@ -238,6 +238,11 @@ module nurdz.game
// The question mark key; this is not in ts-game-engine yet. // The question mark key; this is not in ts-game-engine yet.
case 191: case 191:
// If we're in debugging mode, don't handle the key here and
// let the debug code handle it instead.
if (this._maze.debugger.debugTracking)
return false;
// Get the AI to select a ball. If one was selected, jump // Get the AI to select a ball. If one was selected, jump
// the player to that position, turn to face it, and push. // the player to that position, turn to face it, and push.
// The push might not work if we're not already facing down, // The push might not work if we're not already facing down,
...@@ -351,6 +356,10 @@ module nurdz.game ...@@ -351,6 +356,10 @@ module nurdz.game
case KeyCodes.KEY_W: case KeyCodes.KEY_W:
return this._debugger.debugWipeMaze (); return this._debugger.debugWipeMaze ();
// The question mark key; this is not in ts-game-engine yet.
case 191:
return this._debugger.debugShowContents ();
// For debugging purposes, this key swaps to human balls // For debugging purposes, this key swaps to human balls
case KeyCodes.KEY_Z: case KeyCodes.KEY_Z:
console.log ("human balls"); console.log ("human balls");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment