fix: wrong position in RMG

This commit is contained in:
Renge 2022-04-13 15:25:42 -04:00
parent 52278cb456
commit 3beaf76980
2 changed files with 5 additions and 1 deletions

View File

@ -39,7 +39,7 @@ export default class Tutorial extends GameLevel{
this.viewport.setBounds(0, -500, this.map.width*32, this.map.height*32);
this.viewport.follow(this.player);
this.playerSpawn = new Vec2(5*32, 9*32);
this.playerSpawn = new Vec2(1*32, 1*32);
// Do generic setup for a GameLevel
super.startScene();

View File

@ -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];