diff --git a/.gitignore b/.gitignore index 66fb270..b9b8c8f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,18 @@ node_modules # Exclude the compiled project dist/* +# Firebase cache +.firebase/ + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +firebase-debug.log* +firebase-debug.*.log* + # Include the demo_assets folder !dist/demo_assets/ diff --git a/src/shattered_sword/Tools/RandomMapGenerator.ts b/src/shattered_sword/Tools/RandomMapGenerator.ts index 940561a..c9cc22f 100644 --- a/src/shattered_sword/Tools/RandomMapGenerator.ts +++ b/src/shattered_sword/Tools/RandomMapGenerator.ts @@ -110,7 +110,7 @@ export default class RandomMapGenerator { } getPlayer(): Vec2 { - return this.player; + return new Vec2(this.player.x - this.minX, this.player.y - this.minY); } getEnemies(): Array { @@ -250,6 +250,10 @@ export default class RandomMapGenerator { for (let room of this.rooms) { let roomWidth = room.bottomRight.x - room.topLeft.x + 1; let roomHeight = room.bottomRight.y - room.topLeft.y + 1; + room.topLeft.x -= this.minX; + room.topLeft.y -= this.minY; + room.bottomRight.x -= this.minX; + room.bottomRight.y -= this.minY; for (let i = 0; i < roomHeight; i++) for (let j = 0; j < roomWidth; j++) { this.map.layers[0].data[(room.topLeft.y + i) * width + room.topLeft.x + j] = room.bottomLayer[i * roomWidth + j]; @@ -257,13 +261,11 @@ export default class RandomMapGenerator { } if (room.enemies) for (let enemy of this.enemies) { - enemy.position.x -= this.minX; - enemy.position.y -= this.minY; + enemy.position.x += room.topLeft.x; + enemy.position.y += room.topLeft.y; this.enemies.push(enemy); } } - this.player.x -= this.minX; - this.player.y -= this.minY; } private isValidRoom(topLeft: Vec2, bottomRight: Vec2): boolean { @@ -353,8 +355,8 @@ export default class RandomMapGenerator { if (old.sprites) { for (let sprite of old.sprites) { if (sprite.type === 'player') { - this.player.x = sprite.x; - this.player.y = sprite.y; + this.player.x = sprite.x + posX; + this.player.y = sprite.y + posY; } else { if (this.gen.random() <= sprite.possibility) {