diff --git a/apps.json b/apps.json index 3a390938d..c213fdaa6 100644 --- a/apps.json +++ b/apps.json @@ -5393,7 +5393,7 @@ { "id": "puzzle15", "name": "15 puzzle", - "version": "0.04", + "version": "0.05", "description": "A 15 puzzle game with drag gesture interface", "readme":"README.md", "icon": "puzzle15.app.png", diff --git a/apps/puzzle15/ChangeLog b/apps/puzzle15/ChangeLog index bd6af53d8..0950b7ae0 100644 --- a/apps/puzzle15/ChangeLog +++ b/apps/puzzle15/ChangeLog @@ -2,3 +2,4 @@ 0.02: Lots of enhancements, menu system not yet functional, but packaging should be now... 0.03: Menu logic now generally functioning, splash screen added. The first really playable version! 0.04: Settings dialog, about screen +0.05: Central game end function diff --git a/apps/puzzle15/puzzle15.app.js b/apps/puzzle15/puzzle15.app.js index e66f9b9bb..eec21933c 100644 --- a/apps/puzzle15/puzzle15.app.js +++ b/apps/puzzle15/puzzle15.app.js @@ -391,23 +391,23 @@ class Board { //this.setAlmostSolved(); // to test the game end } - /* - // Set the board into the "solved" position. Useful for showcasing + /* Set the board into the "solved" position. Useful for showcasing and development setSolved() { this.stones = []; for (i = 0; i < stonesPerBoard; i++) this.stones[i] = new Stone((i + 1) % stonesPerBoard, i); this.moveCount = 0; } + /* */ - // Initialize an almost solved playing field. Useful for tests and development + /* Initialize an almost solved playing field. Useful for tests and development setAlmostSolved() { this.setSolved(); b = this.stones[this.stones.length - 1]; this.stones[this.stones.length - 1] = this.stones[this.stones.length - 2]; this.stones[this.stones.length - 2] = b; } - */ + /* */ // Initialize a shuffled field. The fields are always solvable. setShuffled() { @@ -671,7 +671,7 @@ function gameEnd(moveCount) { buttons: { "Again": newGame, "Menu": () => showMenu(false), - "Exit": load + "Exit": exitGame } }).then(v => { E.showPrompt(); @@ -702,7 +702,7 @@ function showMenu(withContinue) { mainmenu["Start 4x4"] = () => initGame(4); mainmenu["Start 5x5"] = () => initGame(5); mainmenu.About = () => showAbout(withContinue); - mainmenu.Exit = () => load(); + mainmenu.Exit = exitGame; dragger.setEnabled(false); g.clear(true); E.showMenu(mainmenu); @@ -722,6 +722,12 @@ function handledrag(e) { worker.addTask(e => board.drawResult(e)); } +// exit the game, clear screen first to prevent ghost images +function exitGame() { + g.clear(true); + setTimeout(load, 300); +} + // *** Main program @@ -762,4 +768,4 @@ showSplash(() => { showMenu(false); }); -// end of file +// end of file \ No newline at end of file