This commit is contained in:
OfficialCHenry 2022-04-24 15:15:33 -04:00
commit a65873c349
11 changed files with 239 additions and 118 deletions

View File

@ -52,7 +52,7 @@
"possibility": 1 "possibility": 1
} }
], ],
"checkPoint": [5, 19, 5, 5] "startCheckPoint": [25, 19, 5, 5]
}, },
"exit": { "exit": {
"width": 30, "width": 30,
@ -76,7 +76,8 @@
"width": 3, "width": 3,
"alt_tile": [0, 478] "alt_tile": [0, 478]
} }
] ],
"endCheckPoint": [20, 16, 5, 5]
}, },
"rooms": [ "rooms": [
{ {

View File

@ -3,7 +3,7 @@
"spriteSheetImage": "Hiro.png", "spriteSheetImage": "Hiro.png",
"spriteWidth": 64, "spriteWidth": 64,
"spriteHeight": 64, "spriteHeight": 64,
"columns": 7, "columns": 8,
"rows": 7, "rows": 7,
"durationType": "time", "durationType": "time",
"animations": [ "animations": [
@ -75,12 +75,12 @@
] ]
}, },
{ {
"name": "JUMP", "name": "JUMP2",
"repeat": false, "repeat": false,
"frames": [ "frames": [
{ {
"index": 30, "index": 30,
"duration": 10 "duration": 5
}, },
{ {
"index": 31, "index": 31,
@ -96,12 +96,12 @@
}, },
{ {
"index": 30, "index": 30,
"duration": 10 "duration": 5
} }
] ]
}, },
{ {
"name": "JUMP_RIGHT", "name": "JUMP",
"repeat": false, "repeat": false,
"frames": [ "frames": [
{ {
@ -303,6 +303,32 @@
"duration": 10 "duration": 10
} }
] ]
},
{
"name": "DASH",
"repeat": false,
"frames": [
{
"index": 46,
"duration": 5
},
{
"index": 47,
"duration": 5
},
{
"index": 48,
"duration": 5
},
{
"index": 49,
"duration": 5
},
{
"index": 50,
"duration": 10
}
]
} }
] ]
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -27,7 +27,9 @@ import WeaponTypeRegistry from "./shattered_sword/Registry/WeaponTypeRegistry";
{name: "inventory", keys: ["i","b"]}, {name: "inventory", keys: ["i","b"]},
{name: "pause", keys: ["escape"]}, {name: "pause", keys: ["escape"]},
{name: "tab", keys: ["tab"]}, {name: "tab", keys: ["tab"]},
{name: "spawn", keys: ["q"]} //debug feature to test enemy spawning, press q to spawn enemy at current location {name: "buff1", keys: ["1"]},
{name: "buff2", keys: ["2"]},
{name: "buff3", keys: ["3"]}
], ],
useWebGL: false, // Tell the game we want to use webgl useWebGL: false, // Tell the game we want to use webgl
showDebug: false // Whether to show debug messages. You can change this to true if you want showDebug: false // Whether to show debug messages. You can change this to true if you want

View File

@ -39,6 +39,8 @@ import { TiledTilemapData } from "../../Wolfie2D/DataTypes/Tilesets/TiledData";
import AttackAction from "../AI/EnemyActions/AttackAction"; import AttackAction from "../AI/EnemyActions/AttackAction";
import Move from "../AI/EnemyActions/Move"; import Move from "../AI/EnemyActions/Move";
import GameOver from "./GameOver"; import GameOver from "./GameOver";
import Porcelain from "./Porcelain";
import Tutorial from "./Tutorial";
// TODO // TODO
/** /**
@ -99,36 +101,45 @@ export default class GameLevel extends Scene {
protected gameStateStack: Stack<GameState>; protected gameStateStack: Stack<GameState>;
// Story // Story
private storytextLabel: Label; protected storytextLabel: Label;
private storyLayer: Layer; protected storyLayer: Layer;
private story: Story; protected story: Story;
private storyProgress: number; protected storyProgress: number;
private storySprites: Array<Sprite>; protected storySprites: Array<Sprite>;
private storyBGMs: Array<string>; protected storyBGMs: Array<string>;
private currentSpeaker: string; protected currentSpeaker: string;
private currentContent: string; protected currentContent: string;
//buffs layer //buffs layer
buffLayer: Layer; protected buffLayer: Layer;
buffButton1 : Button; protected buffButton1 : Button;
buffLabel1 : Label; protected buffLabel1 : Label;
buffButton2 : Button; protected buffButton2 : Button;
buffLabel2 : Label; protected buffLabel2 : Label;
buffButton3 : Button; protected buffButton3 : Button;
buffLabel3: Label; protected buffLabel3: Label;
buffs: Array<Buff>; protected buffs: Array<Buff>;
//pause layer //pause layer
pauseLayer: Layer; protected pauseLayer: Layer;
pauseText: Label; protected pauseText: Label;
pauseInput: TextInput; protected pauseInput: TextInput;
pauseSubmit: Label; protected pauseSubmit: Label;
pauseCheatText: Label; protected pauseCheatText: Label;
protected randomSeed: number; protected randomSeed: number;
protected rmg: RandomMapGenerator; protected rmg: RandomMapGenerator;
protected map: TiledTilemapData; protected map: TiledTilemapData;
protected startCheckPoint: Rect;
protected endCheckPoint: Rect;
protected touchedStartCheckPoint: boolean = false;
protected touchedEndCheckPoint: boolean = false;
protected static gameTimer: number = 0;
protected gameStarted: boolean = false;
protected timerLable: Label;
protected levelEnded: boolean = false;
startpos: Vec2; startpos: Vec2;
loadScene(): void { loadScene(): void {
//can load player sprite here //can load player sprite here
@ -198,8 +209,10 @@ export default class GameLevel extends Scene {
this.subscribeToEvents(); this.subscribeToEvents();
this.addUI(); this.addUI();
const checkPoint = this.rmg.getCheckPoint(); let startCheckPoint = this.rmg.getStartCheckPoint();
this.addLevelEnd(new Vec2(checkPoint[0], checkPoint[1]), new Vec2(checkPoint[2], checkPoint[3])); this.startCheckPoint = this.addCheckPoint(new Vec2(startCheckPoint[0], startCheckPoint[1]), new Vec2(startCheckPoint[2], startCheckPoint[3]), "startStory", "startTimer");
let endCheckPoint = this.rmg.getEndCheckPoint();
this.endCheckPoint = this.addCheckPoint(new Vec2(endCheckPoint[0], endCheckPoint[1]), new Vec2(endCheckPoint[2], endCheckPoint[3]), "endStory", "nextLevel");
// Create an enemies array // Create an enemies array
// Send the player and enemies to the battle manager // Send the player and enemies to the battle manager
@ -250,7 +263,30 @@ export default class GameLevel extends Scene {
updateScene(deltaT: number){ updateScene(deltaT: number){
if (this.gameStateStack.peek() === GameState.GAMING) {
if (this.gameStarted) {
GameLevel.gameTimer += deltaT;
this.timerLable.textColor = Color.BLACK;
}
else {
this.timerLable.textColor = Color.RED;
}
let minutes = Math.floor(GameLevel.gameTimer / 60);
if (minutes >= 10) {
this.timerLable.text = minutes.toString();
}
else {
this.timerLable.text = "0" + minutes.toString();
}
let seconds = Math.floor(GameLevel.gameTimer % 60);
if (seconds >= 10) {
this.timerLable.text += ":" + seconds.toString();
}
else {
this.timerLable.text += ":0" + seconds.toString();
}
}
// Handle events and update the UI if needed // Handle events and update the UI if needed
while(this.receiver.hasNextEvent()){ while(this.receiver.hasNextEvent()){
let event = this.receiver.getNextEvent(); let event = this.receiver.getNextEvent();
@ -321,9 +357,23 @@ export default class GameLevel extends Scene {
this.respawnPlayer(); this.respawnPlayer();
} }
else{ //no more lives else{ //no more lives
this.viewport.setZoomLevel(1);
this.sceneManager.changeToScene(GameOver, {}); this.sceneManager.changeToScene(GameOver, {});
InputWrapper.enableInput();
} }
break; break;
case "startStory":
this.playStartStory();
break;
case "endStory":
this.playEndStory();
break;
case "startTimer":
this.startTimer();
break;
case "nextLevel":
this.goToNextLevel();
break;
} }
} }
@ -366,6 +416,16 @@ export default class GameLevel extends Scene {
} }
} }
if (InputWrapper.isBuff1JustPresed()) {
this.emitter.fireEvent("buff1");
}
if (InputWrapper.isBuff2JustPresed()) {
this.emitter.fireEvent("buff2");
}
if (InputWrapper.isBuff3JustPresed()) {
this.emitter.fireEvent("buff3");
}
//update health UI //update health UI
let playerAI = (<PlayerController>this.player.ai); let playerAI = (<PlayerController>this.player.ai);
this.healthLabel.text = "Health: "+ Math.round(playerAI.CURRENT_HP) +'/' + Math.round(playerAI.MAX_HP +playerAI.CURRENT_BUFFS.hp); this.healthLabel.text = "Health: "+ Math.round(playerAI.CURRENT_HP) +'/' + Math.round(playerAI.MAX_HP +playerAI.CURRENT_BUFFS.hp);
@ -398,7 +458,7 @@ export default class GameLevel extends Scene {
// this.expLabel.sizeToText(); // this.expLabel.sizeToText();
//update level ui //update level ui
this.playerLevelLabel.text = "lv." + playerAI.level; this.playerLevelLabel.text = "Lv." + playerAI.level;
//update lives ui //update lives ui
this.livesCountLabel.text = "Lives: " + playerAI.lives; this.livesCountLabel.text = "Lives: " + playerAI.lives;
@ -410,36 +470,6 @@ export default class GameLevel extends Scene {
const baseViewportSize = this.viewport.getHalfSize().scaled(2); const baseViewportSize = this.viewport.getHalfSize().scaled(2);
//check position of player //check position of player
this.playerFalloff(viewportCenter, baseViewportSize); this.playerFalloff(viewportCenter, baseViewportSize);
// Update player safe position
if (this.player.onGround) {
this.playerSpawn = this.player.position.clone();
}
//TODO - this is for testing
/*
if(InputWrapper.isSpawnJustPressed()){
console.log("trying to spawn enemy");
this.addEnemy("test_dummy",this.player.position,{player: this.player,
health :100,
tilemap: "Main",
//actions:actions,
goal: Statuses.REACHED_GOAL,
actions: [new AttackAction(3, [Statuses.IN_RANGE], [Statuses.REACHED_GOAL]),
new Move(2, [], [Statuses.IN_RANGE], {inRange: 60})],
status : [Statuses.CAN_RETREAT, Statuses.CAN_BERSERK],
weapon : this.createWeapon("knife")
});
}
*/
if (InputWrapper.isInventoryJustPressed()) {
console.log("LoadingStory");
this.storyLoader("shattered_sword_assets/jsons/story.json");
}
} }
// TODO put UI changes in here // TODO put UI changes in here
@ -501,6 +531,10 @@ export default class GameLevel extends Scene {
this.receiver.subscribe("buff2"); this.receiver.subscribe("buff2");
this.receiver.subscribe("buff3"); this.receiver.subscribe("buff3");
this.receiver.subscribe("cheat"); this.receiver.subscribe("cheat");
this.receiver.subscribe("startStory");
this.receiver.subscribe("startTimer");
this.receiver.subscribe("endStory");
this.receiver.subscribe("nextLevel");
} }
// TODO - // TODO -
@ -543,8 +577,12 @@ export default class GameLevel extends Scene {
this.playerLevelLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(30, 95), text: "lv. "+ (<PlayerController>this.player.ai).level }); this.playerLevelLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(20, 95), text: "Lv. "+ (<PlayerController>this.player.ai).level });
this.playerLevelLabel.size.set(0, 50);
this.playerLevelLabel.setHAlign(HAlign.LEFT);
this.playerLevelLabel.textColor = Color.BLUE; this.playerLevelLabel.textColor = Color.BLUE;
this.playerLevelLabel.font = "PixelSimple";
this.playerLevelLabel.fontSize = 25;
this.expLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(100, 95), text: "EXP: "+ (<PlayerController>this.player.ai).CURRENT_EXP }); this.expLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(100, 95), text: "EXP: "+ (<PlayerController>this.player.ai).CURRENT_EXP });
this.expLabel.size.set(200, 50); this.expLabel.size.set(200, 50);
@ -691,9 +729,12 @@ export default class GameLevel extends Scene {
this.pauseSubmit.onClickEventId = "cheat"; this.pauseSubmit.onClickEventId = "cheat";
this.pauseSubmit.borderWidth = 3; this.pauseSubmit.borderWidth = 3;
this.livesCountLabel = <Label>this.add.uiElement(UIElementType.LABEL, "UI", {position: new Vec2(600, 30), text:"Lives: "}); this.livesCountLabel = <Label>this.add.uiElement(UIElementType.LABEL, "UI", {position: new Vec2(this.viewport.getHalfSize().x*2 - 100, 30), text:"Lives: "});
this.livesCountLabel.textColor = Color.YELLOW; this.livesCountLabel.textColor = Color.YELLOW;
this.livesCountLabel.fontSize = 25;
this.timerLable = <Label>this.add.uiElement(UIElementType.LABEL, "UI", {position: new Vec2(Math.floor(this.viewport.getHalfSize().x), 30), text: "00:00"});
this.timerLable.fontSize = 60;
} }
//TODO - determine whether we will have weapon datatype //TODO - determine whether we will have weapon datatype
@ -736,8 +777,6 @@ export default class GameLevel extends Scene {
* Initializes the player * Initializes the player
*/ */
protected initPlayer(): void { protected initPlayer(): void {
//create the inventory //create the inventory
let inventory = new InventoryManager(this, 1, "inventorySlot", new Vec2(16, 16), 4, "slots1", "items1"); let inventory = new InventoryManager(this, 1, "inventorySlot", new Vec2(16, 16), 4, "slots1", "items1");
@ -848,8 +887,6 @@ export default class GameLevel extends Scene {
//TODO - give each enemy unique weapon //TODO - give each enemy unique weapon
protected initializeEnemies( enemies: Enemy[]){ protected initializeEnemies( enemies: Enemy[]){
let actionsDefault = [new AttackAction(3, [Statuses.IN_RANGE], [Statuses.REACHED_GOAL]), let actionsDefault = [new AttackAction(3, [Statuses.IN_RANGE], [Statuses.REACHED_GOAL]),
new Move(2, [], [Statuses.IN_RANGE], {inRange: 60}), new Move(2, [], [Statuses.IN_RANGE], {inRange: 60}),
]; ];
@ -934,11 +971,12 @@ export default class GameLevel extends Scene {
} }
protected addLevelEnd(startingTile: Vec2, size: Vec2): void { protected addCheckPoint(startingTile: Vec2, size: Vec2, enter: string, exit: string): Rect {
this.levelEndArea = <Rect>this.add.graphic(GraphicType.RECT, "primary", {position: startingTile.scale(32), size: size.scale(32)}); let checkPoint = <Rect>this.add.graphic(GraphicType.RECT, "primary", {position: startingTile.scale(32), size: size.scale(32)});
this.levelEndArea.addPhysics(undefined, undefined, false, true); checkPoint.addPhysics(undefined, undefined, false, true);
// this.levelEndArea.setTrigger("player", somelevelendevent, null); checkPoint.setTrigger("player", enter, null);
this.levelEndArea.color = new Color(0, 0, 0, 0); checkPoint.color = new Color(0, 0, 0, 0);
return checkPoint;
} }
@ -1003,7 +1041,7 @@ export default class GameLevel extends Scene {
* @param viewportCenter The center of the viewport * @param viewportCenter The center of the viewport
* @param viewportSize The size of the viewport * @param viewportSize The size of the viewport
*/ */
playerFalloff(viewportCenter: Vec2, viewportSize: Vec2):void{ protected playerFalloff(viewportCenter: Vec2, viewportSize: Vec2):void{
if(this.player.position.y >= viewportCenter.y +viewportSize.y/2.0){ if(this.player.position.y >= viewportCenter.y +viewportSize.y/2.0){
this.player.position.set(this.playerSpawn.x,this.playerSpawn.y); this.player.position.set(this.playerSpawn.x,this.playerSpawn.y);
@ -1016,7 +1054,37 @@ export default class GameLevel extends Scene {
} }
async storyLoader(storyPath: string) { protected playStartStory() {
if (!this.touchedStartCheckPoint) {
this.touchedStartCheckPoint = true;
this.storyLoader("shattered_sword_assets/jsons/story.json");
this.startTimer();
}
}
protected playEndStory() {
if (!this.touchedEndCheckPoint) {
this.touchedEndCheckPoint = true;
this.storyLoader("shattered_sword_assets/jsons/story.json");
this.endTimer();
this.levelEnded = true;
}
}
protected startTimer() {
this.gameStarted = true;
}
protected endTimer() {
this.gameStarted = false;
}
protected goToNextLevel() {
// this.sceneManager.changeToScene(Porcelain);
}
protected async storyLoader(storyPath: string) {
if (this.gameStateStack.peek() === GameState.STORY) { if (this.gameStateStack.peek() === GameState.STORY) {
return; return;
} }
@ -1053,11 +1121,11 @@ export default class GameLevel extends Scene {
this.updateStory(); this.updateStory();
} }
hasNextStory(): boolean { protected hasNextStory(): boolean {
return this.gameStateStack.peek() === GameState.STORY && this.storyProgress + 1 < this.story.texts.length; return this.gameStateStack.peek() === GameState.STORY && this.storyProgress + 1 < this.story.texts.length;
} }
updateStory() { protected updateStory() {
if (this.hasNextStory()) { if (this.hasNextStory()) {
this.storyProgress++; this.storyProgress++;
let tmp = undefined; let tmp = undefined;
@ -1130,11 +1198,14 @@ export default class GameLevel extends Scene {
this.story = undefined; this.story = undefined;
this.storytextLabel = undefined; this.storytextLabel = undefined;
// this.storyLayer = undefined; // this.storyLayer = undefined;
if (this.levelEnded) {
this.goToNextLevel();
}
} }
} }
// Cheat // Cheat
enableCheat() { protected enableCheat() {
if (this.pauseInput.text.toUpperCase() === "UUDDLRLRBABA") { if (this.pauseInput.text.toUpperCase() === "UUDDLRLRBABA") {
(<PlayerController>this.player._ai).godMode = true; (<PlayerController>this.player._ai).godMode = true;
} }

View File

@ -1,18 +1,31 @@
import Vec2 from "../../Wolfie2D/DataTypes/Vec2"; import Vec2 from "../../Wolfie2D/DataTypes/Vec2";
import Input from "../../Wolfie2D/Input/Input";
import Label from "../../Wolfie2D/Nodes/UIElements/Label"; import Label from "../../Wolfie2D/Nodes/UIElements/Label";
import { UIElementType } from "../../Wolfie2D/Nodes/UIElements/UIElementTypes"; import { UIElementType } from "../../Wolfie2D/Nodes/UIElements/UIElementTypes";
import Scene from "../../Wolfie2D/Scene/Scene"; import Scene from "../../Wolfie2D/Scene/Scene";
import Color from "../../Wolfie2D/Utils/Color"; import Color from "../../Wolfie2D/Utils/Color";
import { GameState } from "../sword_enums";
import InputWrapper from "../Tools/InputWrapper";
import MainMenu from "./MainMenu";
export default class GameOver extends Scene { export default class GameOver extends Scene {
startScene() { startScene() {
InputWrapper.setState(GameState.PAUSE);
const center = this.viewport.getCenter(); const center = this.viewport.getCenter();
this.addUILayer("primary"); this.addUILayer("primary");
const gameOver = <Label>this.add.uiElement(UIElementType.LABEL, "primary", {position: new Vec2(center.x, center.y), text: "Game Over"}); const gameOver = <Label>this.add.uiElement(UIElementType.LABEL, "primary", {position: new Vec2(center.x, center.y), text: "YOU DIED"});
gameOver.textColor = Color.WHITE; gameOver.textColor = Color.RED;
gameOver.fontSize = 100;
const hint = <Label>this.add.uiElement(UIElementType.LABEL, "primary", {position: new Vec2(center.x, center.y + 100), text: "Click to go back to Main Menu"});
hint.textColor = Color.WHITE;
}
updateScene(){
if(InputWrapper.isLeftMouseJustPressed()){
this.sceneManager.changeToScene(MainMenu);
}
} }
} }

View File

@ -21,9 +21,6 @@ export default class MainMenu extends Scene {
private about: Layer; private about: Layer;
private control: Layer; private control: Layer;
// private rmg: RandomMapGenerator; // private rmg: RandomMapGenerator;
animatedSprite: AnimatedSprite;
loadScene(): void { loadScene(): void {
// Load the menu song // Load the menu song
@ -33,24 +30,6 @@ export default class MainMenu extends Scene {
//TODO //TODO
startScene(): void{ startScene(): void{
// this.config = new ConfigManager();
// this.save = new SaveManager();
// console.log(this.config.getVolume());
// this.config.setVolume(100);
// console.log(this.config.getVolume());
// console.log(this.save.getLevel());
// this.save.setLevel(10);
// console.log(this.save.getLevel());
// this.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", 114514);
// this.rmg.getMap();
// Scene has started, so start playing music
//this.emitter.fireEvent(GameEventType.PLAY_SOUND, {key: "menu", loop: true, holdReference: true});
const center = this.viewport.getCenter(); const center = this.viewport.getCenter();
// The main menu // The main menu

View File

@ -13,6 +13,8 @@ import EnemyAI from "../AI/EnemyAI";
import BattlerAI from "../AI/BattlerAI"; import BattlerAI from "../AI/BattlerAI";
import AttackAction from "../AI/EnemyActions/AttackAction"; import AttackAction from "../AI/EnemyActions/AttackAction";
import Move from "../AI/EnemyActions/Move"; import Move from "../AI/EnemyActions/Move";
import Porcelain from "./Porcelain";
import MainMenu from "./MainMenu";
export default class Tutorial extends GameLevel { export default class Tutorial extends GameLevel {
loadScene(): void { loadScene(): void {
@ -54,4 +56,9 @@ export default class Tutorial extends GameLevel {
}) })
} }
} }
protected goToNextLevel(): void {
this.viewport.setZoomLevel(1);
this.sceneManager.changeToScene(Porcelain);
}
} }

View File

@ -50,7 +50,8 @@ export class RoomTemplate {
topLayer: Array<number>; topLayer: Array<number>;
entrances: Array<Entrance>; entrances: Array<Entrance>;
sprites?: Array<Sprite>; sprites?: Array<Sprite>;
checkPoint?: [number, number, number, number]; startCheckPoint?: [number, number, number, number];
endCheckPoint?: [number, number, number, number];
} }
export class Corner { export class Corner {

View File

@ -103,15 +103,25 @@ export default class InputWrapper {
return false; return false;
} }
static isSpawnJustPressed(): boolean { static isBuff1JustPresed(): boolean{
if (InputWrapper.gameState != GameState.GAMING) { if (InputWrapper.gameState != GameState.BUFF) {
return false; return false;
} }
return Input.isJustPressed("buff1");
if (Input.isJustPressed("spawn")) { }
return true;
static isBuff2JustPresed(): boolean{
if (InputWrapper.gameState != GameState.BUFF) {
return false;
} }
return false; return Input.isJustPressed("buff2");
}
static isBuff3JustPresed(): boolean{
if (InputWrapper.gameState != GameState.BUFF) {
return false;
}
return Input.isJustPressed("buff3");
} }
static isPauseJustPressed(): boolean { static isPauseJustPressed(): boolean {

View File

@ -25,7 +25,8 @@ export default class RandomMapGenerator {
private exitFacing: Facing; private exitFacing: Facing;
private enemies: Array<Enemy>; private enemies: Array<Enemy>;
private player: Vec2; private player: Vec2;
private checkPoint: [number, number, number, number]; private startCheckPoint: [number, number, number, number];
private endCheckPoint: [number, number, number, number];
constructor(JSONFilePath: string, seed: any) { constructor(JSONFilePath: string, seed: any) {
let xhr = new XMLHttpRequest(); let xhr = new XMLHttpRequest();
@ -45,7 +46,8 @@ export default class RandomMapGenerator {
this.rooms = new Array(); this.rooms = new Array();
this.enemies = new Array(); this.enemies = new Array();
this.player = new Vec2(); this.player = new Vec2();
this.checkPoint = [0,0,0,0]; this.startCheckPoint = [0,0,0,0];
this.endCheckPoint = [0, 0, 0, 0];
let gen = require('random-seed'); let gen = require('random-seed');
this.gen = new gen(seed); this.gen = new gen(seed);
this.hasExit = false; this.hasExit = false;
@ -117,8 +119,12 @@ export default class RandomMapGenerator {
return new Vec2(this.player.x - this.minX, this.player.y - this.minY); return new Vec2(this.player.x - this.minX, this.player.y - this.minY);
} }
getCheckPoint(): [number, number, number, number] { getStartCheckPoint(): [number, number, number, number] {
return [this.checkPoint[0] - this.minX, this.checkPoint[1] - this.minY, this.checkPoint[2], this.checkPoint[3]]; return [this.startCheckPoint[0] - this.minX, this.startCheckPoint[1] - this.minY, this.startCheckPoint[2], this.startCheckPoint[3]];
}
getEndCheckPoint(): [number, number, number, number] {
return [this.endCheckPoint[0] - this.minX, this.endCheckPoint[1] - this.minY, this.endCheckPoint[2], this.endCheckPoint[3]];
} }
getEnemies(): Array<Enemy> { getEnemies(): Array<Enemy> {
@ -378,10 +384,15 @@ export default class RandomMapGenerator {
} }
} }
} }
if (old.checkPoint) { if (old.startCheckPoint) {
this.checkPoint = [...old.checkPoint]; this.startCheckPoint = [...old.startCheckPoint];
this.checkPoint[0] += posX; this.startCheckPoint[0] += posX;
this.checkPoint[1] += posY; this.startCheckPoint[1] += posY;
}
if (old.endCheckPoint) {
this.endCheckPoint = [...old.endCheckPoint];
this.endCheckPoint[0] += posX;
this.endCheckPoint[1] += posY;
} }
if (posX < this.minX) if (posX < this.minX)
this.minX = posX; this.minX = posX;