# TIC-TAC-TOE V1.01 # Freeware # By Alex Garza (02/10/97) # e-mail: agarza@mail.giga.com # # Please wait while program is # being loded... for x=5 to 35 : grline x,130,x,140 : next x new #clear screen 10 o=fn 42 # draw grid 20 for i=20 to 140 step 40 30 grline i,20,i,140 40 grline 20,i,140,i 50 next i # init arrays 60 dim z (9) 70 for j=1 to 9 : z(j)=0 : next j 80 dim w(8) for x=36 to 65 : grline x,130,x,140 : next # main loop 90 for j=1 to 9 100 gosub 320 110 p=x+((y-1)*3) 120 x=x*40-20 130 y=y*40-20 # validate pen entry 140 if x<20 or x>130 then 190 150 if y<20 or y>130 then 190 # space occupied 180 if (z(p)=0) then goto 210 190 sound 440,18,64,"S" 200 goto 100 for x=66 to 95 : grline x,130,x,140 : next 210 m=j mod 2 220 z(p)=1+m*10 230 if m = 0 then gosub 400 240 if m =1 then gosub 500 250 gosub 600 260 next j 264 gosub 320 266 if j=10 then goto 290 270 if m=1 then ? "X Won !" 280 if m=0 then ? "O Won !" 290 input "Play again ? (y/n)",p$ 300 if p$="n" then end 310 goto 10 #read pen 320 t1=fn 34 330 t2=fn 34 340 if (t1=t2) then goto 330 345 sound 1000,80,64,"t" 350 x=(peek(0x1c4,2)+20)/40 360 y=(peek(0x1c6,2)+20)/40 370 return for x=96 to 125 : grline x,130,x,140 : next # draw circle 400 grline x+20,y+3,x+37,y+20 410 grline x+37,y+20,x+20,y+37 420 grline x+20,y+37,x+3,y+20 430 grline x+3,y+20,x+20,y+3 440 return # draw cross 500 grline x+5,y+5,x+35,y+35 510 grline x+35,y+5,x+5,y+35 520 return # check who won 600 w(1)=z(1)+z(2)+z(3) 610 w(2)=z(4)+z(5)+z(6) 620 w(3)=z(7)+z(8)+z(9) 630 w(4)=z(1)+z(4)+z(7) 640 w(5)=z(2)+z(5)+z(8) 650 w(6)=z(3)+z(6)+z(9) 660 w(7)=z(1)+z(5)+z(9) 670 w(8)=z(7)+z(5)+z(3) 680 for i=1 to 8 690 if (w(i)=3) or (w(i)=33) then goto 720 700 next i 710 return for x=126 to 155 : grline x,130,x,140 : next 720 j=10 730 d=((i-1) mod 3 +1)*40 740 if i<4 then grline 22,d,138,d 750 if i>3 and i<7 then grline d,22,d,138 760 if i=7 then grline 22,22,138,138 770 if i=8 then grline 138,22,22,138 780 sound 800,80,64,"tt" 800 return sound 1000,80,64,"tt" sound 400,80,64,"tt" run