diff --git a/dist/shattered_sword_assets/jsons/forest_template.json b/dist/shattered_sword_assets/jsons/forest_template.json index 7d5a1d0..a919c2c 100644 --- a/dist/shattered_sword_assets/jsons/forest_template.json +++ b/dist/shattered_sword_assets/jsons/forest_template.json @@ -22,6 +22,13 @@ "width": 3, "alt_tile": [477, 479] } + ], + "sprites": [ + { + "type": "player", + "x": 5, + "y": 19 + } ] }, "exit": { diff --git a/src/shattered_sword/Scenes/Tutorial.ts b/src/shattered_sword/Scenes/Tutorial.ts index 1535d24..16e35bb 100644 --- a/src/shattered_sword/Scenes/Tutorial.ts +++ b/src/shattered_sword/Scenes/Tutorial.ts @@ -10,6 +10,7 @@ import { UIElementType } from "../../Wolfie2D/Nodes/UIElements/UIElementTypes"; export default class Tutorial extends GameLevel{ private map: TiledTilemapData; + private rmg: RandomMapGenerator; loadScene(): void { @@ -18,8 +19,8 @@ export default class Tutorial extends GameLevel{ // this.load.tilemap("forest1", "shattered_sword_assets/tilemaps/Tutorial.json"); // let map = localStorage.getItem("map"); this.randomSeed = Math.floor(Math.random()*10000000000); - let rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", this.randomSeed); - this.map = rmg.getMap(); + this.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", this.randomSeed); + this.map = this.rmg.getMap(); this.load.tilemapFromObject("forest1", this.map); this.load.spritesheet("player", "shattered_sword_assets/spritesheets/Hiro.json") @@ -36,10 +37,11 @@ export default class Tutorial extends GameLevel{ // Add the level 1 tilemap this.add.tilemap("forest1", new Vec2(2, 2)); console.log("width,height:"+this.map.width,this.map.height); - this.viewport.setBounds(0, -500, this.map.width*32, this.map.height*32); + this.viewport.setBounds(0, 0, this.map.width*32, this.map.height*32); this.viewport.follow(this.player); - this.playerSpawn = new Vec2(5*32, 9*32); + console.log(this.rmg.getPlayer().toString()); + this.playerSpawn = this.rmg.getPlayer().scale(32); // Do generic setup for a GameLevel super.startScene(); diff --git a/src/shattered_sword/Tools/RandomMapGenerator.ts b/src/shattered_sword/Tools/RandomMapGenerator.ts index c9cc22f..40e9c29 100644 --- a/src/shattered_sword/Tools/RandomMapGenerator.ts +++ b/src/shattered_sword/Tools/RandomMapGenerator.ts @@ -252,8 +252,6 @@ export default class RandomMapGenerator { 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]; @@ -362,7 +360,7 @@ export default class RandomMapGenerator { if (this.gen.random() <= sprite.possibility) { let tmp = new Enemy(); tmp.type = sprite.type; - tmp.position = new Vec2(posX + sprite.x, posY + sprite.y); + tmp.position = new Vec2(sprite.x, sprite.y); room.enemies.push(tmp); } }