diff --git a/dist/shattered_sword_assets/jsons/porcelain_template.json b/dist/shattered_sword_assets/jsons/porcelain_template.json index 765bf70..8a35779 100644 --- a/dist/shattered_sword_assets/jsons/porcelain_template.json +++ b/dist/shattered_sword_assets/jsons/porcelain_template.json @@ -24,7 +24,15 @@ "width": 3, "alt_tile": [11, 11] } + ], + "sprites": [ + { + "type": "player", + "x": 5, + "y": 10 + } ] + }, "exit": { "width": 30, diff --git a/src/shattered_sword/Tools/RandomMapGenerator.ts b/src/shattered_sword/Tools/RandomMapGenerator.ts index 751ff38..1764cff 100644 --- a/src/shattered_sword/Tools/RandomMapGenerator.ts +++ b/src/shattered_sword/Tools/RandomMapGenerator.ts @@ -94,10 +94,12 @@ export default class RandomMapGenerator { getMap(): TiledTilemapData { let room = this.copyRoom(this.template.entrance, 0, 0); - this.rooms.push(room); - let facing = this.getEntranceFacing(this.template.entrance.entrances[0], this.template.entrance.width); let position = new Vec2(this.template.entrance.entrances[0].x, this.template.entrance.entrances[0].y); + // this.removeEntrance(room, this.template.entrance.entrances[0], facing); + this.rooms.push(room); + + this.putNextRoom(position, this.getOppositeFacing(facing)); @@ -134,7 +136,7 @@ export default class RandomMapGenerator { default: break; } - if (this.roomPlaced >= this.minRoom && facing == this.exitFacing) { + if (this.roomPlaced >= this.minRoom && facing == this.exitFacing && !this.hasExit) { this.putExitRoom(position); return true; } @@ -155,9 +157,10 @@ export default class RandomMapGenerator { return false; } let room = this.copyRoom(nextRoom, nextPosition.x, nextPosition.y); + this.removeEntrance(room, thisEntrance, facing); this.rooms.push(room); this.roomPlaced += 1; - if (this.hasExit && this.gen.range() <= 0.5) { + if (this.hasExit && this.gen.random() <= 0.3) { return false; } for (let entrance of nextRoom.entrances) {