* * * * * * * * * * * * * * * * * * * * * * * * MINE FIELD Construction Kit * * * * * * * * * * * * * * * * * * * * * * * * Unless otherwise specified, all coordinates are expressed * in units of "tiles" (1-40 horizontally, 1-25 vertically). * *------------------------------------------------------------------------- * Task drawfield ( Int a , Int b , Int c , Int d ) * * Draws a field of gray tiles inside a gray frame. * * Enter with: * * (a,b) - the coordinates of the upper-left tile in the frame. * (c,d) - the coordinates of the lower-right tile in the frame. * Task plantmine ( Int x , Int y ) * * Puts a mine at location (x,y) if no mine is already there. * Task removemine ( Int x , Int y ) * * Removes a mine from location (x,y) if a mine is there. * Task plantmines ( Int n ) * * Randomly fills the field with mines. * (Each tile has 1/n chance of receiving a mine.) * Task shownulls * * Uncovers all tiles whose mine proximity count is zero. * Task autoproc ( Int mode , Int err , Int x , Int y ) * * Uncovers and/or marks all tiles whose identities are "obvious". * * Enter with: * mode=0, (do nothing) * mode=1, mark all obvious tiles * mode=2, uncover all obvious tiles * mode=3, mark and uncover all obvious tiles * * Return with: * err=0, no mines were uncovered * err<0, then (x,y) is location of uncovered mine * Task togglemarker ( Int x , Int y ) * * Toggles on or off the mine marker on tile (x,y) * Task reveal ( Int x , Int y , Int z ) * * Uncovers the tile at location (x,y) and displays * the mine proximity count for that location. If * no mine is uncovered, returns z=0. If a mine is * revealed, it is displayed on a red square, and the * value -1 is returned in z. * Task testfordone ( Int z ) * * Looks to see if all tiles have been either uncovered * or marked as mines. If so, returns z=1. Otherwise, * returns z=0. * Task showmines * * Reveals all unmarked mines in the field. * If a tile was incorrectly marked, a red * "X" is displayed on that tile. * Task pixeltotile ( Int x , Int y ) * * Converts the numerical values of (x,y) from pixel * coordinates [640x480] into tile coordinates [40x25]. * Task tiletopixel ( Int x , Int y ) * * Converts the numerical values of (x,y) from tile * coordinates [40x25] into pixel coordinates [640x480] * centered on the tile. * Task status ( Int x , Int y , Int visible , Int marked , Int mine ) * * Returns the current state of the tile located at (x,y): * * visible - 0: tile has not yet been revealed * 4: tile has been revealed * marked - 0: tile is not currently marked as covering a mine * 2: tile is currently marked as covering a mine * mine - 0: tile is not actually covering a mine * 1: tile is actually covering a mine * Task neighbors ( Int x , Int y , Int visible , Int marked , Int mines ) * * Returns the proximity counts [0-8] for the tile located at (x,y): * * visible: number of neighboring tiles that have been revealed * marked: number of neighboring tiles that have been marked * mines: number of neighboring tiles that are covering a mine * * Task waitmouse ( Int x , Int y , Int z ) * * Waits until a mouse button is pushed and released. * It then returns the current location (x,y) of the * mouse (in tile coordinates) along with the button * value (z). * * [If a graphics button on the screen has been pressed, * returns in z the negative id value of the button. If * the 'Esc' key is pressed, terminates the program.] * Task drawbutton ( Int id , Text label , Int color ) * * Draws a gray button on the screen at the current cursor position. * * Enter with: * id - the button's ID number (1-32) * label - the label to be drawn on the button * color - the color of the surrounding rectangle * * Task victory * * Plays a bugle call. * *------------------------------------------------------------------------- * * [The following tasks are intended for internal use only, but are made * available for those advanced users who may want to access them.] * Task drawmine ( Int x , Int y ) Task drawoops ( Int x , Int y ) Task drawredx ( Int x , Int y ) Task drawtextile ( Text t , Int color , Int x , Int y ) Task drawtile ( Int x , Int y )