diff --git a/modules/levelSelection.mjs b/modules/levelSelection.mjs index 9f6b89f..20c94e5 100644 --- a/modules/levelSelection.mjs +++ b/modules/levelSelection.mjs @@ -9,6 +9,8 @@ export const selectLevel = (ctx, gameState, id) => { // TODO transfer expireFunction without a fail // const expireFunc = () => {gameState.timer.expireFunction();}; gameState.timer.setTime(levelsBlueprint[id].time); + gameState.playable = true; + gameState.tutorial.hide(); gameState.playground.draw(ctx, gameState.width, gameState.height); } diff --git a/modules/levels.mjs b/modules/levels.mjs index 7fcb9d1..72bc2aa 100644 --- a/modules/levels.mjs +++ b/modules/levels.mjs @@ -66,7 +66,7 @@ const level5Blueprint = { [Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Wall, Square.Floor, Square.Box, Square.Floor, Square.Wall, Square.Floor, Square.Wall, Square.Wall, Square.Wall, ], [Square.Wall, Square.Destination, Square.Destination, Square.Destination, Square.Destination, Square.Floor, Square.Floor, Square.Wall, Square.Wall, Square.Floor, Square.Box, Square.Floor, Square.Floor, Square.Box, Square.Floor, Square.Floor, Square.Wall, ], [Square.Wall, Square.Wall, Square.Destination, Square.Destination, Square.Destination, Square.Floor, Square.Floor, Square.Floor, Square.Floor, Square.Box, Square.Floor, Square.Floor, Square.Box, Square.Floor, Square.Floor, Square.Floor, Square.Wall, ], - [Square.Wall, Square.Destination, Square.Destination, Square.Destination, 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.Destination, Square.Destination, Square.Destination, Square.Destination, 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, 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, Square.Wall, ], ], time: 40000 diff --git a/modules/tutorialControler.mjs b/modules/tutorialControler.mjs index 3b77a17..aec1207 100644 --- a/modules/tutorialControler.mjs +++ b/modules/tutorialControler.mjs @@ -11,14 +11,21 @@ export class TutorialControler { self.messageBox = document.getElementById('tutorial-box'); self.messageId = 0; self.messageBox.innerHTML = TutorialControler.messages[self.messageId]; + self.hide = () => { + document.getElementById('tutorial-speech-bubble').style.visibility = "hidden"; + self.finished = true; + } + } + + hide() { + self.hide(); } next() { if (!self.finished) { self.messageId++; if (self.messageId == TutorialControler.messages.length) { - document.getElementById('tutorial-speech-bubble').style.visibility = "hidden"; - self.finished = true; + self.hide(); } else { self.messageBox.innerHTML = TutorialControler.messages[self.messageId]; } @@ -28,4 +35,5 @@ export class TutorialControler { isFinished() { return self.finished; } + } diff --git a/script.js b/script.js index 729a77e..4d3a61a 100644 --- a/script.js +++ b/script.js @@ -31,10 +31,9 @@ let gameState = { gameState.timer.stop(); } ), levelId: 0, + tutorial: new TutorialControler(), }; -let tutorial = new TutorialControler(); - fillLevelsSelection(gameState, ctx); window.ctx = ctx window.addEventListener("keydown", (event) => { @@ -66,11 +65,11 @@ window.addEventListener("keydown", (event) => { case "ArrowRight": case " ": case "Enter": - tutorial.next(); - if (tutorial.isFinished()) { - gameState.playable = true; - gameState.timer.start(); - } + gameState.tutorial.next(); + if (gameState.tutorial.isFinished()) { + gameState.playable = true; + gameState.timer.start(); + } break; default: break;