home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / tcl / tcl_1 / !oxo_!Help < prev    next >
Encoding:
Text File  |  1994-09-07  |  1.6 KB  |  48 lines

  1. oxo - shade demonstration program
  2.  
  3. This plays the game of noughts and crosses.
  4.  
  5. The filer needs to have seen the !Tcl directory before it will run
  6. It needs RISCOS 3.1 or greater.
  7.  
  8. You play O, the computer plays X. 
  9.  
  10. Initially you have the first move. Subsequently the loser of the previous
  11. game moves first, the move switches after a draw. Play by clicking on the board.
  12. If the "Wait" option is ticked in the board menu the computer will wait for
  13. you to click again before playing.
  14.  
  15. The program plays with a very simple algorithm, I don't know if it can be 
  16. beaten.
  17.  
  18. ================================================================================
  19.  
  20. The program gives a simple example of how to use draw graphics in shade.
  21.  
  22. The w_draw commands at the end of the file create the board.
  23.  
  24. The makemove procedure makes the move after the computer or player has chosen
  25. it. This includes updating the variables game(X), game(O) and free. These  
  26. contain the numbers of squares that have O, X or nothing in them.
  27.  
  28. The line
  29.  
  30.    set board($z) [w_draw mainwin text [point $z] $player -fn@50p -ocm ]
  31.  
  32. draws the O or X. Notice the number of the draw text object is stored in
  33. the array board so that the board can be cleared in the restart procedure.
  34.  
  35. The procedure "point" calculates the coordinates of the center of a square 
  36. on the board. Note the use of "-ocm" to center the letter.
  37.  
  38. If someone has won the command
  39.  
  40.        set board($line)\
  41.          [w_draw mainwin above -1 path\
  42.            [point [string index $line 0]]-[point [string index $line 2]]\
  43.            -t.05i -c255:0:0\
  44.          ]
  45.  
  46. draws the line through the three letters. Notice the use of "above -1" to
  47. ensure the line is on top.
  48.