forked from FOSS/BangleApps
commit
722ac51468
19
apps.json
19
apps.json
|
@ -5389,5 +5389,24 @@
|
|||
"storage": [
|
||||
{"name":"touchmenu.boot.js","url":"touchmenu.boot.js"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "puzzle15",
|
||||
"name": "15 puzzle",
|
||||
"version": "0.05",
|
||||
"description": "A 15 puzzle game with drag gesture interface",
|
||||
"readme":"README.md",
|
||||
"icon": "puzzle15.app.png",
|
||||
"screenshots": [{"url":"screenshot.png"}],
|
||||
"type": "app",
|
||||
"tags": "game",
|
||||
"supports": ["BANGLEJS2"],
|
||||
"allow_emulator": true,
|
||||
"storage": [
|
||||
{"name":"puzzle15.app.js","url":"puzzle15.app.js"},
|
||||
{"name":"puzzle15.settings.js","url":"puzzle15.settings.js"},
|
||||
{"name":"puzzle15.img","url":"puzzle15.app-icon.js","evaluate":true}
|
||||
],
|
||||
"data": [{"name":"puzzle15.json"}]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
0.01: Initial version, UI mechanics ready, no real game play so far
|
||||
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
|
|
@ -0,0 +1,57 @@
|
|||
# Puzzle15 - A 15-puzzle for the Bangle.js 2
|
||||
|
||||
This is a Bangle.js 2 adoption of the famous 15 puzzle.
|
||||
|
||||
## The game
|
||||
|
||||
A board of _n_ by _n_ fields is filled with _n^2-1_ numbered stones. So, one field, the "gap", is left free.
|
||||
|
||||
Bring them in the correct order so that the gap is finally at the bottom right of the playing field.
|
||||
The less moves you need, the better you are.
|
||||
|
||||
If _n_ is 4, the number of stones is _16-1=15_. Hence the name of the game.
|
||||
|
||||
## How to play
|
||||
|
||||
If you start the game, it shows a splash screen and then generates a shuffled 4x4 board with a 15 puzzle.
|
||||
Move the stones with drag gestures on the screen.
|
||||
If you want to move the stone below the gap upward, drag from the bottom of the screen upward.
|
||||
The drag gestures can be performed anywhere on the screen, there is no need to start or end them on the stone to be moved.
|
||||
|
||||
If you managed to order the stones correctly, a success message appears.
|
||||
You can continue with another game, go to the game's main menu, or quit the game entirely.
|
||||
|
||||
There is a grey menu button right of the board containing the well-known three-bar menu symbol ("Hamburger menu").
|
||||
It opens the game's main menu directly from within the game.
|
||||
|
||||
## The main menu
|
||||
|
||||
Puzzle15 has a main menu which can be reached from the in-game menu button or the end-of-game message window.
|
||||
It features the following options:
|
||||
|
||||
* **Continue** - Continue the currently running game. _This option is only shown if the main menu is opened during an open game._
|
||||
* **Start 3x3**, **Start 4x4**, **Start 5x5** - Start a new game on a board with the respective dimension. Any currently open game is dropped.
|
||||
* **About** Show a small "About" info box.
|
||||
* **Exit** Exit Puzzle15 and return to the default watch face.
|
||||
|
||||
## Game settings
|
||||
|
||||
The game has some global settings which can be accessed on the usual way through the Bangle.js' app settings user interface.
|
||||
Currently it has the following options:
|
||||
|
||||
* **Splash** - Define whether the game should open with a splash screen. **long** shows the splash screen for five seconds, **short** shows it for two seconds. **off** starts the app _without_ a splash screen, it directly comes up with whatever the "Start with" option says.
|
||||
* **Start with** - What should happen after the splash screen (or, if it is disabled, directly at app start): **3x3**, **4x4** and **5x5** start the game with a board of the respective dimension, **menu** shows the main menu which allows to select the board size.
|
||||
|
||||
## Implementation notes
|
||||
|
||||
The game engine always generates puzzles which can be solved.
|
||||
|
||||
Solvability is detected by counting inversions,
|
||||
i.e. pairs of stones where the stone at the earlier field (row-wise, left to right, top to bottom) has a number _greater than_ the stone on the later field, with all pairs of stones compared.
|
||||
The algorithm is described at https://www.geeksforgeeks.org/check-instance-15-puzzle-solvable/ .
|
||||
|
||||
## The splash screen
|
||||
|
||||
The Splash screen shows a part of the illustration "The 14-15-puzzle in puzzleland" from Sam Loyd. Other than Puzzle15, it depicts a 15 puzzle with the stones "14" and "15" swapped. This puzzle is indeed *not* solvable.
|
||||
|
||||
Have fun!
|
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwgn/AC3+7oAD7e7AAW8BQndBQe79/9DomgHocH74KD/RJE34Xax4XDtvoC4fJ54XDluAC4f2z4XDzm/C4ett4XD34OBF4e/I4m+C4f8r4XChHuC5U98oXEF4cP7/AC5O9mYXC/2/F4cGtwvE/SsBC4Ws7gvD7YCBL4ULO4i/u1QAD7QED1e6AoetCAnf/YeE1wpD/lgBQcKIAgXG14LD/twC5kL3Z+BC4P+LgIXBg272wXD7wXEh7eCC4PWzIXChHtOoIXB/WX54XDh3KmAXC1oLBI4UD+AXC+/rdIIvD5wvD3O4C4cJ4AXC/dUI4kJhgMBC4Ov+AXDh9QC4X2/gvEhvvoAXC81dC4duR4f8wSncC6v8u4AD3ndAAXcy4KDtYKD7vf/oGE2wRDvPNBQfLFAnP/o2EVIIACg7yBAATZBAAe/C7P9g4XCx+wn/6C4Op//AC4MK+cI/+QC4X2/fPC4PM2HKh8H7vpewIXBhvThV5+AXC+/5C4UL2HHC4Pf/P/AIJHB6cAj2wC4X+3AXPhADBF4fX94XB1va1vOC4PXAIX6hfrxvb0CPD7p3C1e6hW2C4LOBAIIXB3eJ3YXEX78GM4IAC9QXG1QAD7QEDJYIFD14oE//7DwgME/twBQcPC70G6EG5dQ1/8VYPtC4ObgfM5IXHr/whvO4Gvy6LBtX9vfugnr3AXHkXggGOC4P97/43X9ukOgnv6BfIC4Oe2AXC6+nI4MOgfI9QXJhssF4f91AXCgnA9IXHr3u1HusGv3Ob//s/t693l3xHJX9v+3YAD7oAE5YKD34XFAC4="))
|
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
|
@ -0,0 +1,50 @@
|
|||
// Settings menu for the Puzzle15 app
|
||||
|
||||
(function(back) {
|
||||
var FILE = "puzzle15.json";
|
||||
// Load settings
|
||||
var settings = Object.assign({
|
||||
splashMode: "long",
|
||||
startWith: "4x4"
|
||||
}, require('Storage').readJSON(FILE, true) || {});
|
||||
|
||||
function writeSettings() {
|
||||
require('Storage').writeJSON(FILE, settings);
|
||||
}
|
||||
|
||||
// Helper method which uses int-based menu item for set of string values
|
||||
function stringItems(startvalue, writer, values) {
|
||||
return {
|
||||
value: (startvalue === undefined ? 0 : values.indexOf(startvalue)),
|
||||
format: v => values[v],
|
||||
min: 0,
|
||||
max: values.length - 1,
|
||||
wrap: true,
|
||||
step: 1,
|
||||
onchange: v => {
|
||||
writer(values[v]);
|
||||
writeSettings();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Helper method which breaks string set settings down to local settings object
|
||||
function stringInSettings(name, values) {
|
||||
return stringItems(settings[name], v => settings[name] = v, values);
|
||||
}
|
||||
|
||||
var mainmenu = {
|
||||
"": {
|
||||
"title": "15 Puzzle"
|
||||
},
|
||||
"< Back": () => back(),
|
||||
"Splash": stringInSettings("splashMode", ["long", "short", "off"]),
|
||||
"Start with": stringInSettings("startWith", ["3x3", "4x4", "5x5", "menu"])
|
||||
};
|
||||
|
||||
// Actually display the menu
|
||||
E.showMenu(mainmenu);
|
||||
|
||||
});
|
||||
|
||||
// end of file
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue