diff --git a/extra/minesweeper/minesweeper-docs.factor b/extra/minesweeper/minesweeper-docs.factor new file mode 100644 index 0000000000..c9aa42649a --- /dev/null +++ b/extra/minesweeper/minesweeper-docs.factor @@ -0,0 +1,37 @@ +USING: help.markup help.syntax ; + +IN: minesweeper + +ARTICLE: "minesweeper" "Minesweeper" +"The game starts with a grid of cells. Some cells contain a mine, others do not. If you click on a cell containing a mine, you " { $strong "lose" } " (it blows up!). If you click on all the cells (without clicking on any mines), you " { $strong "win" } "!" +$nl +"Three levels of difficulties are available:" +$nl +{ $table + { { $strong "Difficulty" } { $strong "Grid Size" } { $strong "Mines" } } + { "Easy" { $snippet "8 x 8" } "10" } + { "Medium" { $snippet "16 x 16" } "40" } + { "Hard" { $snippet "16 x 30" } "99" } +} +$nl +"The upper left corner contains a counter of the number of mines left to find. This number will update as you flag or unflag cells." +$nl +"The upper right corner contains a timer. This timer will count the number of seconds since beginning to play, maxing out at " { $snippet "999" } " (16 minutes and 39 seconds)." +$nl +"Clicking on a cell which doesn't have a mine reveals the number of neighboring cells that contain mines. Use this information (plus good guessing!) to avoid the mines." +$nl +"To open a cell, point at the cell with your mouse and click on it. The first cell you click to open is never a mine." +$nl "Every cell has up to 8 neighbors: the cells adjacent above, below, left, right, and all 4 diagonals. The cells on the sides of the board (and its corners) have fewer neighbors." +$nl +"If you open a cell with no neighboring mines all of its neighbors will automatically open. This can sometimes be a large area." +$nl +"To flag a cell you think is a mine, point and right-click (or hover with the mouse and press " { $snippet "SPACE" } "). Do this again to mark with a question mark symbol (useful if you are unsure about a cell). Do this again to return the cell to blank." +$nl +"If you flag a mine incorrectly, you will need to correct that mistake before you can win." +$nl +"You do not have to flag all the mines to win, you only need to open all the cells that do not contain mines." +$nl +"Click the yellow smiley face (or the desired difficulty) to start a new game." +; + +ABOUT: "minesweeper" diff --git a/extra/minesweeper/minesweeper.factor b/extra/minesweeper/minesweeper.factor index 368ab79010..5b7bfca746 100644 --- a/extra/minesweeper/minesweeper.factor +++ b/extra/minesweeper/minesweeper.factor @@ -7,7 +7,7 @@ destructors formatting fry images.loader kernel locals math math.order math.parser namespaces opengl opengl.textures random sequences timers ui ui.commands ui.gadgets ui.gadgets.toolbar ui.gadgets.tracks ui.gadgets.worlds ui.gestures ui.pens.solid -ui.render words ; +ui.render ui.tools.browser words ; IN: minesweeper @@ -202,7 +202,7 @@ M: grid-gadget pref-dim* :: draw-timer ( n gadget -- ) gadget pref-dim first :> width - n "%03d" sprintf [ + n 999 min "%03d" sprintf [ 3 swap - 26 * width swap - 3 - 6 2array [ digit-image-path gadget draw-cached-texture ] with-translation @@ -280,10 +280,13 @@ M: grid-gadget draw-gadget* : com-hard ( gadget -- ) 16 30 99 new-game ; +: com-help ( gadget -- ) drop "minesweeper" com-browse ; + grid-gadget "toolbar" f { { T{ key-down { sym "1" } } com-easy } { T{ key-down { sym "2" } } com-medium } { T{ key-down { sym "3" } } com-hard } + { T{ key-down { sym "?" } } com-help } } define-command-map grid-gadget "gestures" [