Addons/games/minesweeper

From J Wiki
Jump to navigation Jump to search
User Guide Installation Development Categories Git Build Log

games/minesweeper - Basic implementation of classic Minesweeper game using different Graphic User Interfaces.

The main purpose of this addon is to compare and contrast the different GUI building technologies available for J.

Minefield.png

The following UI implementations are available:

Script UI toolset
uiconsole.ijs Text-based
uiwd.ijs J6's Window Driver (wd) GUI
uigtk.ijs J7 gui/gtk (defines the form programatically)
uigtkglade.ijs J7 gui/gtk (defines the form as an XML file created using the interactive Glade form designer)

The console interface should work from all front ends, including JHS. The Gtk interfaces should work from either the Jconsole or the Gtk environment.

Browse the addon source using Trac.

Install

Use Package Manager to install the games/minesweeper addon.

Run

Below are some examples of running various UI versions. Obviously you can only run some scripts in a compatible environment, so the uiwd.ijs script can currently be run using only J6, and the gui/gtk based scripts will run only in J7.

   load 'games/minesweeper/uiwd'
   MinesweeperWd ''

   load 'games/minesweeper/uigtk'
   MinesweeperGtk ''

   load 'games/minesweeper/uigtk'
   MinesweeperGtk 20 20

   load 'games/minesweeper/uigtkglade'
   MinesweeperGtkGlade ''

   load 'games/minesweeper/uiconsole'
   fld=: MinesweeperCon ''

Motivation

The engine for this game began as a solution to a RosettaCode programming task. It then seemed to be a nice simple application that might serve as a type of Rosetta stone itself, showing how to translate a GUI from the J6 window driver (wd) toolset to the new J7 Gtk toolset.

Further development

As J tools and Application Program Interfaces for working with Gtk evolve, the Gtk scripts should hopefully get shorter and less complex.

Ideas for extending the game:

  • Create a child dialog for the Game|Options menu item, that among other things could enable the user to change the size and/or difficulty of the minefield
  • Make the minefield image resize to fit the current window
  • Display a timer that counts the length of time used in clearing the field
  • Record "high" scores for various-sized minefields
  • When the player loses, display the mine that was cleared differently from other mines in the revealed map
  • Add sound
  • It may be possible to create an interactive, GUI version of the game for the JHS front end.

Authors

Ric Sherlock, Bill Lam, Raul Miller