tutoriel disparait quand on selectionne un autre niveau
This commit is contained in:
parent
766cdaa003
commit
40e609fea3
4 changed files with 19 additions and 10 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
13
script.js
13
script.js
|
@ -30,10 +30,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) => {
|
||||
|
@ -65,11 +64,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;
|
||||
|
|
Loading…
Reference in a new issue