Code: Alles auswählen
Dim T(8)
s.s=" ist dran"
l=OpenWindow(0,216,0,190,260,$CC<<16,"TicTacToe")
CreateGadgetList(l)
For a=0 To8
  ButtonGadget(a,10+60*a%3,10+60*(a/3),50,50,"")
  SetGadgetFont(a,LoadFont(a,"",24))
Next
ButtonGadget(11,10,220,80,30,"Neues Spiel")
ButtonGadget(10,100,220,80,30,"Spiel Beenden")
TextGadget(9,10,190,170,20,"O"+s,1)
SetGadgetFont(9,LoadFont(9,"",12))
Repeat
  w=WindowEvent()
  If w=13100
    O=EventwParam()
    If O=10
      End
    ElseIf O=11
      For a=0 To9
        T(a)=0
        SetGadgetText(a,"")
        DisableGadget(a,0)
      Next
      P=0
    Else
      If T(O)=0
        T(O)=P+1
        DisableGadget(O,1)
        SetGadgetText(O,Chr(79+P*9))
        SetGadgetText(9,Chr(79+P!1*9)+s)
        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(79+P*9)+" gewinnt")
            For a=0 To 8
              DisableGadget(a,1)
            Next
          EndIf
        Next
        P!1
      EndIf
    EndIf
  EndIf
Until w=16
