Class TBoard
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----Board
|
+----TBoard
- class TBoard
- extends Board
TBoard
TicTacToe Board
this file is designed to be an example for creating games for jGames
-the comment "DNR" (do not remove) means that this method or variable
musn't be removed but should be changed to fit the game you are coding
-the comment "DNC" (do not change) means that this method or variable
must be there and left as it's.
-
-
if TBoard is an extension of Board it's because I included some "tools"
in Board that are usefull to build a game, and like this, there is no
need to rewrite or copy those methods.
* tool list
* hidden tools
1- Board do the translation between absolut coordinates and image
like this you don't have to bother about the position of your board.
(see tW(),tH(), mouseDown() and paint() )
2- Board do all the double buffering thing which avoid the image to
flicker.
(see update() and paint())
-
* not hidden tool
getImage(String name) will return you an image from the directory where
the applet was downloaded
- Version:
- 1.0b1 25/04/98
-
crossd
- this is the width of a cross picture divided by 2
-
horizBoard
- if you want the Board to be horizontal set this to true
-
myH
- heigth of the board
-
myW
- width of the board (in this case width of the picture I use)
-
picts
- the array in which I'll store images 0 for background
1 for player's crosses 2 for opponent crosses
-
tab
- Array that gives the start board
-
TBoard()
- Constructror
-
getClickValue(int, int)
- This method is called by mouseDown() each time a bol is clicked.
-
init(Gpanel)
- initialization of the Board
this method is called only once, at the start of the Game.
-
paintBoard(Graphics)
- this method is each time the player receive
a new array representing the game Board.
tab
int tab[]
- Array that gives the start board
myW
int myW
- width of the board (in this case width of the picture I use)
myH
int myH
- heigth of the board
horizBoard
boolean horizBoard
- if you want the Board to be horizontal set this to true
crossd
int crossd
- this is the width of a cross picture divided by 2
picts
Image picts[]
- the array in which I'll store images 0 for background
1 for player's crosses 2 for opponent crosses
TBoard
public TBoard()
- Constructror
init
public void init(Gpanel o)
- initialization of the Board
this method is called only once, at the start of the Game.
- Overrides:
- init in class Board
paintBoard
public void paintBoard(Graphics gr)
- this method is each time the player receive
a new array representing the game Board.
this is where you draw a new board.
gr is the Graphics on which you will draw, it's automgically double
buffered and centered on the player's Frame
- Overrides:
- paintBoard in class Board
getClickValue
public void getClickValue(int xC,
int yC)
- This method is called by mouseDown() each time a bol is clicked.
It determine on which square the player clicked,
and gives the position in the array of this clicked
square to owner.play() .
xC and yC represents the coordinates in the Image you draw in
paintBoard(Graphics gr);
- Overrides:
- getClickValue in class Board