M src/game.js => src/game.js +2 -0
@@ 92,6 92,8 @@ export function drawBox(box) {
if (box.failed) {
boxG.lineStyle(2, hsv(0, .5, .8));
+ } else if (gameData.selectedBox === box) {
+ boxG.lineStyle(2, hsv(.6, .5, .8));
} else {
boxG.lineStyle(2, hsv(.3, .5, .8));
}
M src/main.js => src/main.js +16 -0
@@ 132,6 132,10 @@ function play (delta) {
}
});
gameData.dataPieces = gameData.dataPieces.filter(piece => !piece.consumedBy);
+
+ if (gameData.selectedBox) {
+ gameData.debugText.text = '\n' + JSON.stringify(gameData.selectedBox.data, null, 2);
+ }
}
function save () {
@@ 181,6 185,8 @@ function reset () {
gameData.dataPieces = [];
Array.from(gameData.connections).forEach(connection => removeConnection(piece, gameData, gs))
load(localStorage.save);
+ gameData.selectedBox = null;
+ gameData.debugText.text = '';
}
window.save = save;
@@ 606,6 612,16 @@ function mousedown (e) {
object: boxClicked,
offset: boxClicked.pos.mul(TILE_SIZE).sub(gameData.mouse)
}
+
+ const lastSelectedBox = gameData.selectedBox;
+ gameData.selectedBox = boxClicked;
+ if (lastSelectedBox) {
+ drawBox(lastSelectedBox);
+ }
+ if (gameData.selectedBox) {
+ drawBox(gameData.selectedBox);
+ }
+ window.$b = gameData.selectedBox
}
} else if (e.button === 2) {
if (boxClicked) {