please kill me

This commit is contained in:
2024-04-28 09:40:13 -07:00
parent 98f57d50bd
commit aa31bb8df8
8 changed files with 264 additions and 4 deletions
+12 -1
View File
@@ -3,6 +3,7 @@ class Player {
this.mainEl = document.querySelector('main.dispGrid');
this.x = startx;
this.y = starty;
this.mainEl.children[this.y].children[this.x].classList.add("player");
this.setupEventListeners();
}
@@ -16,7 +17,17 @@ class Player {
moveTo(newX, newY) {
const square = this.mainEl.children[newY]?.children[newX];
if (square?.classList?.contains('room')) {
if (square?.classList?.contains('room') && !square?.classList?.contains('visited')) {
const roomTiles = findConnectedRooms(square);
roomTiles.map(r => r.classList.add('visited'));
const edgeTiles = findEdgeRooms(roomTiles);
// recreate outer box
const boundingRect = calculateBoundingRectangle(edgeTiles.map(r => r.room));
const scale = calculateScalingFactor(boundingRect);
scaleToFitScreen(edgeTiles, scale, boundingRect);
// for now, just move through it
this.mainEl.children[this.y].children[this.x].classList.remove('player');
square.classList.add('player');