home *** CD-ROM | disk | FTP | other *** search
- oxo - shade demonstration program
-
- This plays the game of noughts and crosses.
-
- The filer needs to have seen the !Tcl directory before it will run
- It needs RISCOS 3.1 or greater.
-
- You play O, the computer plays X.
-
- Initially you have the first move. Subsequently the loser of the previous
- game moves first, the move switches after a draw. Play by clicking on the board.
- If the "Wait" option is ticked in the board menu the computer will wait for
- you to click again before playing.
-
- The program plays with a very simple algorithm, I don't know if it can be
- beaten.
-
- ================================================================================
-
- The program gives a simple example of how to use draw graphics in shade.
-
- The w_draw commands at the end of the file create the board.
-
- The makemove procedure makes the move after the computer or player has chosen
- it. This includes updating the variables game(X), game(O) and free. These
- contain the numbers of squares that have O, X or nothing in them.
-
- The line
-
- set board($z) [w_draw mainwin text [point $z] $player -fn@50p -ocm ]
-
- draws the O or X. Notice the number of the draw text object is stored in
- the array board so that the board can be cleared in the restart procedure.
-
- The procedure "point" calculates the coordinates of the center of a square
- on the board. Note the use of "-ocm" to center the letter.
-
- If someone has won the command
-
- set board($line)\
- [w_draw mainwin above -1 path\
- [point [string index $line 0]]-[point [string index $line 2]]\
- -t.05i -c255:0:0\
- ]
-
- draws the line through the three letters. Notice the use of "above -1" to
- ensure the line is on top.
-