mirror of https://github.com/espruino/BangleApps
Puzzle15: v0.05: Central game end function
parent
3633078a46
commit
cabb0c2d7d
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue