The SilverCreator Plaza
Home Help Search Login RegisterCurrent time:  

Page Index Toggle Pages: 1
Send Topic Print
Tic-Tac-Toe (Read 295 times)
Hendo
God Member
*****
Offline


OH HAI! Wut r goin on
in this forum?

Posts: 1275
Ontario, Canada
Gender: male
Tic-Tac-Toe
Feb 1st, 2007 at 1:13pm
 
It's simple...tic-tac-toe...I feel like i shoudln't be releasing it because Equanox basically recoded the whole thing but whatever....

Link: http://hendosoft.macintoshdevelopers.net/files/tictactoe.zip
Source and graphics included in the zip file.
Back to top
 

...
WWW  
IP Logged
 
EqwanoX
God Member
*****
Offline



Posts: 1782
Gender: male
Re: Tic-Tac-Toe
Reply #1 - Feb 1st, 2007 at 11:53pm
 
yea but that was to show you that haveing most of the code in a method makes it easier to edit when bug checking cause that way you only have to edit one method and not nine click areas, makeing things as simple as possable will save you alot of frustration in the future. also you copy and pasted the wincheck code after every check when it only needs to be in there once at the end, and all the checks were supposed to be in one FOR NEXT command, the "z" variable is the player number, you shouldnt use tabs, it doesnt format right. the RESULTCHECK method shouldve looked like this:


FOR z = 1 to 2
   IF square1 = z THEN
     IF square2 = z THEN
        IF square3 = z THEN
           LET win = z
        END IF
     END IF
   END IF
   
   IF square4 = z THEN
     IF square5 = z THEN
        IF square6 = z THEN
           LET win = z
        END IF
     END IF
   END IF
   
   IF square7 = z THEN
     IF square8 = z THEN
        IF square9 = z THEN
           LET win = z
        END IF
     END IF
   END IF
   
   IF square1 = z THEN
     IF square4 = z THEN
        IF square7 = z THEN
           LET win = z
        END IF
     END IF
   END IF
   
   IF square2 = z THEN
     IF square5 = z THEN
        IF square8 = z THEN
           LET win = z
        END IF
     END IF
   END IF
   
   IF square3 = z THEN
     IF square6 = z THEN
        IF square9 = z THEN
           LET win = z
        END IF
     END IF
   END IF
   
   IF square1 = z THEN
     IF square5 = z THEN
        IF square9 = z THEN
            LET win = z
        END IF
     END IF
   END IF
   
   IF square3 = z THEN
     IF square5 = z THEN
        IF square7 = z THEN
           LET win = z
        END IF
     END IF
   END IF
NEXT
 
IF win > 0 THEN                                //then check for the win at the end here
      IF win = 1 THEN
         NOTEALERT "Player 1 Wins!"
      ELSE
         NOTEALERT "Player 2 Wins!"
      END IF
      FOR x = 1 to 9
         IF SPRITEVALID (x) = true THEN
            KILLSPRITE x, true
         END IF
      NEXT
      GOTOCARD 1
END IF
Back to top
 

...
macintosh 8500/150 OS8.0
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print