Main Page | Class List | File List | Class Members

minezj Class Reference

The java.applet.Applet extending class which represents simple implementation of minesweeper game. More...

List of all members.

Public Member Functions

String getAppletInfo ()
 Provides applet information text.
void init ()
 Applet initialization routine.
void reset_game ()
 Prepares all stuff for new game.
void start ()
 Starts a brand new game.
boolean mouseDown (Event e, int x, int y)
 Evaluate mouse button press event and perform action according to current state of the game.
void paint (Graphics g)
 Paint applet's window.
synchronized void update (Graphics g)
 update applet's window.

Private Member Functions

boolean is_empty (int x, int y)
 Queries is empty and there are no mine fields surrounding it.
void revealcount (int x, int y)
 Uncovers a field specified by position.
void zeroafter909 (int x, int y)
 Recursively uncover all adjoining empty fields starting at specified position.
void do_draw (Graphics g)
 Repaint whole scene.

Private Attributes

Image buffer
 Screen buffer.
Graphics screen
 Screen destination.
byte[] pground
 Battlefield.
Image[] img
 Array containing all sprites.
boolean fl_done
 Game state (true => game done).
int screen_x
 Applet screen width.
int screen_y
 Applet screen height.
int bgcolor = 0xE0E0E0
 Default background color.
int nr_mines = 85
 Number of mines in the game.
int size_x = 30
 Playground's width (number of cells).
int size_y = 15
 Playground's height (number of cells).
int nr_uncovered = 0
 Count of uncovered fields.
final byte F_MINE = 9
 Mine field.
final byte B_UNCOVERED = 0x10
 Uncovered field.
final byte B_MARKED = 0x20
 Marked field (mine suspection).
final byte COUNT_MASK = 0x0F
 Low-nibble mask. It holds count of surrounding mines (0-8).
final byte C_SIZE = 15
 Cell size in pixels.


Detailed Description

The java.applet.Applet extending class which represents simple implementation of minesweeper game.

Definition at line 11 of file minezj.java.


Member Function Documentation

void minezj.do_draw Graphics  g  )  [private]
 

Repaint whole scene.

Parameters:
g Graphics object to paint to.

Definition at line 296 of file minezj.java.

References B_MARKED, B_UNCOVERED, bgcolor, C_SIZE, COUNT_MASK, F_MINE, fl_done, img, nr_mines, nr_uncovered, pground, screen_x, screen_y, size_x, and size_y.

Referenced by update().

void minezj.init  ) 
 

Applet initialization routine.

Acquires basic information and loads graphics from disk.

Definition at line 40 of file minezj.java.

References bgcolor, buffer, img, pground, screen, screen_x, screen_y, size_x, and size_y.

boolean minezj.is_empty int  x,
int  y
[private]
 

Queries is empty and there are no mine fields surrounding it.

Parameters:
x Field x-coordinate.
y Field y-coordinate.
Returns:
boolean True if the field specified by [x,y] is empty and there's no mine field in it's neighbourhood.

Definition at line 149 of file minezj.java.

References pground, and size_x.

Referenced by zeroafter909().

boolean minezj.mouseDown Event  e,
int  x,
int  y
 

Evaluate mouse button press event and perform action according to current state of the game.

In case that game is not running new one is started. In case that game runs left click reveals a field and right click toggles mine suspection flag.

Parameters:
e Event description object.
x Mouse x-coordinate.
y Mouse y-coordinate.

Definition at line 221 of file minezj.java.

References B_MARKED, B_UNCOVERED, C_SIZE, COUNT_MASK, F_MINE, fl_done, nr_mines, nr_uncovered, pground, reset_game(), size_x, size_y, and zeroafter909().

void minezj.paint Graphics  g  ) 
 

Paint applet's window.

Parameters:
g Graphics object to paint to.

Definition at line 275 of file minezj.java.

References update().

void minezj.reset_game  ) 
 

Prepares all stuff for new game.

Initializes needed variables, and generates new playground.

Definition at line 67 of file minezj.java.

References F_MINE, fl_done, nr_mines, nr_uncovered, pground, size_x, and size_y.

Referenced by mouseDown(), and start().

void minezj.revealcount int  x,
int  y
[private]
 

Uncovers a field specified by position.

Parameters:
x Field x-coordinate.
y Field y-coordinate.

Definition at line 158 of file minezj.java.

References B_UNCOVERED, COUNT_MASK, nr_uncovered, pground, and size_x.

Referenced by zeroafter909().

synchronized void minezj.update Graphics  g  ) 
 

update applet's window.

Parameters:
g Graphics object to paint to.

Definition at line 283 of file minezj.java.

References buffer, do_draw(), and screen.

Referenced by paint().

void minezj.zeroafter909 int  x,
int  y
[private]
 

Recursively uncover all adjoining empty fields starting at specified position.

This method may be called recursively.

Parameters:
x Starting field x-coordinate.
y Starting field y-coordinate.

Definition at line 170 of file minezj.java.

References B_UNCOVERED, is_empty(), nr_uncovered, pground, revealcount(), size_x, and size_y.

Referenced by mouseDown().


The documentation for this class was generated from the following file:
Generated on Thu Jan 26 22:02:52 2006 for MinezJ by  doxygen 1.4.3