Skip to content

Commit

Permalink
Add some comments to window.startGame
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdubbelboer committed Oct 21, 2023
1 parent c76ab91 commit 5159503
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,22 @@ function init(extension) {
}
});

// window.startGame is called by the menu to start the game.
window.startGame = () => {
if (gameStarted) {
return;
}
gameStarted = true;

// When the loader isn't done yet, we show the loading screen
// and wait for the loader to finish.
if (!loader.done) {
if (loadingWrapper) {
loadingWrapper.style.display = 'block';
}

loader.once('done', () => {
// Set gameStarted to false so the check above works again.
gameStarted = false;
window.startGame();
});
Expand Down

0 comments on commit 5159503

Please sign in to comment.