Code: Alles auswählen
Dim T(9)
s.s=" ist dran"
t=79
c=190
CreateGadgetList(OpenWindow(0,0,0,c,250,1,"TicTacToe"))
For a=0 To8
  ButtonGadget(a,70*a%3,70*(a/3),50,50,"")
  SetGadgetFont(a,LoadFont(a,"",24))
Next
TextGadget(9,0,c,c,20,"O"+s,1)
c/2
ButtonGadget(c,0,220,c,30,"Neu")
ButtonGadget(t,c,220,c,30,"Ende")
SetGadgetFont(9,LoadFont(9,"",12))
1:
  w=WindowEvent()
  If w>999
    O=EventwParam()
    If O=t
      End
    ElseIf O=c
      For a=0 To9
        T(a)=0
        SetGadgetText(a,"")
        DisableGadget(a,0)
      Next
      P=0
    Else
      If T(O)=0
        T(O)=P+SetGadgetText(9,Chr(t+P!1*9)+s)
        DisableGadget(O,SetGadgetText(O,Chr(t+P*9)))
        j=P+1
        For i=0 To2
          x=i*3
          If T(x)&T(x+1)&T(x+2)=j Or T(i)&T(i+3)&T(i+6)=j Or T(0)&T(4)&T(8)=j Or T(2)&T(4)&T(6)=j
            SetGadgetText(9,Chr(t+P*9)+" gewinnt")
            For a=0 To8
              DisableGadget(a,1)
            Next
          EndIf
        Next
        P!1
      EndIf
    EndIf
  EndIf
Goto 1