diff --git a/src/shattered_sword/Scenes/GameLevel.ts b/src/shattered_sword/Scenes/GameLevel.ts index c6be5e6..0c97bc8 100644 --- a/src/shattered_sword/Scenes/GameLevel.ts +++ b/src/shattered_sword/Scenes/GameLevel.ts @@ -28,13 +28,14 @@ import Layer from "../../Wolfie2D/Scene/Layer"; import Button from "../../Wolfie2D/Nodes/UIElements/Button"; import { Buff } from "../Player/PlayerController"; import CanvasNode from "../../Wolfie2D/Nodes/CanvasNode"; -import { Enemy } from "../Tools/RandomMapGenerator"; +import RandomMapGenerator, { Enemy } from "../Tools/RandomMapGenerator"; import Stack from "../../Wolfie2D/DataTypes/Stack"; import InputWrapper from "../Tools/InputWrapper"; import Story from "../Tools/DataTypes/Story"; import Sprite from "../../Wolfie2D/Nodes/Sprites/Sprite"; import Platformer from "../../demos/Platformer"; import TextInput from "../../Wolfie2D/Nodes/UIElements/TextInput"; +import { TiledTilemapData } from "../../Wolfie2D/DataTypes/Tilesets/TiledData"; @@ -108,18 +109,16 @@ export default class GameLevel extends Scene { pauseInput: TextInput; pauseSubmit: Label; - randomSeed: number; + protected randomSeed: number; + protected rmg: RandomMapGenerator; + protected map: TiledTilemapData; startpos: Vec2; loadScene(): void { //can load player sprite here - - //can load enemy sprite here - //sprites obtained from cse380 sprite wesbite - this.load.spritesheet("Tiger","shattered_sword_assets/spritesheets/Tiger.json"); - this.load.spritesheet("remus_werewolf","shattered_sword_assets/spritesheets/remus_werewolf.json"); - this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json"); - + this.load.spritesheet("player", "shattered_sword_assets/spritesheets/Hiro.json") + // TODO - change when done testing + this.load.spritesheet("slice", "shattered_sword_assets/spritesheets/slice.json"); // Load the scene info this.load.object("weaponData", "shattered_sword_assets/data/weaponData.json"); @@ -140,10 +139,19 @@ export default class GameLevel extends Scene { this.enemies = new Array(); this.battleManager = new BattleManager(); - + this.randomSeed = Math.floor(Math.random() * 10000000000); } startScene(): void { + this.add.tilemap("map", new Vec2(2, 2)); + console.log("width,height:" + this.map.width, this.map.height); + this.viewport.setBounds(0, 0, this.map.width * 32, this.map.height * 32); + this.viewport.follow(this.player); + + this.playerSpawn = this.rmg.getPlayer().scale(32); + console.log(this.playerSpawn) + + this.startpos = this.rmg.getPlayer().scale(32); //call super after extending story with scene @@ -183,6 +191,10 @@ export default class GameLevel extends Scene { } }); + let enemies = this.rmg.getEnemies(); + //may have to move this to start scene in gameLevel + this.initializeEnemies(enemies); + /* this.levelTransitionTimer = new Timer(500); this.levelEndTimer = new Timer(3000, () => { diff --git a/src/shattered_sword/Scenes/Tutorial.ts b/src/shattered_sword/Scenes/Tutorial.ts index 763ab22..c962d91 100644 --- a/src/shattered_sword/Scenes/Tutorial.ts +++ b/src/shattered_sword/Scenes/Tutorial.ts @@ -13,77 +13,21 @@ import EnemyAI from "../AI/EnemyAI"; import BattlerAI from "../AI/BattlerAI"; export default class Tutorial extends GameLevel { - private map: TiledTilemapData; - private rmg: RandomMapGenerator; - - loadScene(): void { super.loadScene(); - // Load resources - // this.load.tilemap("forest1", "shattered_sword_assets/tilemaps/Tutorial.json"); - // let map = localStorage.getItem("map"); - this.randomSeed = Math.floor(Math.random() * 10000000000); 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") - - // TODO - change when done testing - this.load.spritesheet("slice", "shattered_sword_assets/spritesheets/slice.json"); + this.load.tilemapFromObject("map", this.map); //load enemies this.load.spritesheet("Snake","shattered_sword_assets/spritesheets/Snake.json"); this.load.spritesheet("Tiger","shattered_sword_assets/spritesheets/Tiger.json"); - + //can load enemy sprite here + //sprites obtained from cse380 sprite wesbite + this.load.spritesheet("remus_werewolf","shattered_sword_assets/spritesheets/remus_werewolf.json"); + this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json"); //load music here } - - startScene(): void { - - this.startpos = this.rmg.getPlayer().scale(32); - - // 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, 0, this.map.width * 32, this.map.height * 32); - this.viewport.follow(this.player); - - this.playerSpawn = this.rmg.getPlayer().scale(32); - console.log(this.playerSpawn) - - - // Do generic setup for a GameLevel - super.startScene(); - - let enemies = this.rmg.getEnemies(); - /* - for (let enemy of enemies) { - switch (enemy.type) { - case "test_dummy": - this.addEnemy("test_dummy", enemy.position.scale(32), { - player: this.player, - health: 100, - tilemap: "Main", - //actions:actions, - goal: Statuses.REACHED_GOAL, - }) - break; - - default: - break; - } - } - */ - - //may have to move this to start scene in gameLevel - this.initializeEnemies(enemies); - } - - updateScene(deltaT: number): void { - super.updateScene(deltaT); - } - } \ No newline at end of file