diff --git a/index.html b/index.html index 41c256b..e307bfe 100644 --- a/index.html +++ b/index.html @@ -22,11 +22,11 @@
-
+
Time

@@ -34,7 +34,7 @@
-
+
diff --git a/modules/levelSelection.mjs b/modules/levelSelection.mjs index 974d5cc..cc31074 100644 --- a/modules/levelSelection.mjs +++ b/modules/levelSelection.mjs @@ -18,15 +18,20 @@ export const fillLevelsSelection = (gameState, ctx) => { selectionButton.setAttribute("array-index", i); selectionButton.addEventListener("click", (click) => { selectLevel(ctx, gameState, click.srcElement.getAttribute("array-index")); - // let blueprint = levelsBlueprint[ - // click.srcElement.getAttribute("array-index") - // ]; - // gameState.playground = generatePlayground(blueprint.structure, gameState.width, gameState.height); - // gameState.timer = new Timer(blueprint.time, gameState.timer.expireFunction); - // gameState.playground.draw(ctx, gameState.width, gameState.height); }); selectionButton.innerText = "Level" + i; listElement.appendChild(selectionButton); levelList.appendChild(listElement); } } + +export class LevelManager ( + constructor(StartingLevelId = 0) { + self.CurrentLevelId = StartingLevelId; + } + + next(ctx, gameState) { + self.CurrentLevelId++; + selectLevel(ctx, gameState, self.CurrentLevelId); + } +) diff --git a/modules/levels.mjs b/modules/levels.mjs index 346efae..4b6e860 100644 --- a/modules/levels.mjs +++ b/modules/levels.mjs @@ -25,7 +25,23 @@ const level2Blueprint = { time: 23000, }; +const level3Blueprint = { + structure: [ + [Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall,], + [Square.Wall, Square.Floor, Square.Floor, Square.Floor, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall,], + [Square.Wall, Square.Floor, Square.Box, Square.Floor, Square.Destination, Square.Destination, Square.Destination, Square.Wall, Square.Wall, Square.Wall,], + [Square.Wall, Square.Wall, Square.Destination, Square.Box, Square.Box, Square.Destination, Square.Floor, Square.Floor, Square.Wall, Square.Wall,], + [Square.Wall, Square.Wall, Square.Destination, Square.Destination, Square.Floor, Square.Box, Square.Box, Square.Floor, Square.Wall, Square.Wall,], + [Square.Wall, Square.Wall, Square.Destination, Square.Box, Square.Box, Square.Floor, Square.Box, Square.Floor, Square.Floor, Square.Floor], + [Square.Wall, Square.Wall, Square.Player, Square.Destination, Square.Destination, Square.Box, Square.Box, Square.Floor, Square.Floor, Square.Wall,], + [Square.Wall, Square.Wall, Square.Floor, Square.Floor, Square.Floor, Square.Floor, Square.Floor, Square.Wall, Square.Wall, Square.Wall,], + [Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall,], + ], + time: 8000, +} + export const levelsBlueprint = [ level1Blueprint, level2Blueprint, + level3Blueprint, ] diff --git a/modules/timer.mjs b/modules/timer.mjs index 8ecf015..2ecff4e 100644 --- a/modules/timer.mjs +++ b/modules/timer.mjs @@ -2,8 +2,6 @@ export class Timer { readDifficulty(slider) { self.difficulty = 1.5 - slider.value * 0.01; self.time = self.originalTime * self.difficulty; - console.log("difficulty: " + self.difficulty); - console.log("time: " + self.time); } constructor(time, expireFunction) { @@ -48,8 +46,8 @@ export class Timer { if (self.timeRunning) { let timeStr = String(self.time).padStart(5, '0'); self.timerElement.innerHTML = "Time : " + timeStr.slice(0, 3) + '.' + timeStr.slice(3); - if (self.time == 0) { - this.expireFunction(); + if (self.time <= 0) { + self.expireFunction(); clearInterval(self.intervalControler); self.timeRunning = false; }