This commit is contained in:
Ronan 2022-12-12 17:47:34 +01:00
commit 347774b4f2
4 changed files with 19 additions and 10 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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;
}
}

View file

@ -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;