Es ist zwar lang und komplieziert aufgebaucht(ich weiß ich es zu lang gemacht hab)
Wer Lust hat es zu kürzen aber keine Funktion verändert der soll ruhig machen!!!
Code: Alles auswählen
; PureBasic Visual Designer v3.80 build 1249
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#OL
#OM
#OR
#ML
#MM
#MR
#UL
#UM
#UR
#NAchricht
#Spielende
#Neustart
EndEnumeration
;- Fonts
;
Global FontID1
FontID1 = LoadFont(1, "Arial", 24)
Global FontID2
FontID2 = LoadFont(2, "Arial", 12)
Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 190, 260, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Tic Tac Toe")
If CreateGadgetList(WindowID())
ButtonGadget(#OL, 10, 10, 50, 50, "")
SetGadgetFont(#OL, FontID1)
ButtonGadget(#OM, 70, 10, 50, 50, "")
SetGadgetFont(#OM, FontID1)
ButtonGadget(#OR, 130, 10, 50, 50, "")
SetGadgetFont(#OR, FontID1)
ButtonGadget(#ML, 10, 70, 50, 50, "")
SetGadgetFont(#ML, FontID1)
ButtonGadget(#MM, 70, 70, 50, 50, "")
SetGadgetFont(#MM, FontID1)
ButtonGadget(#MR, 130, 70, 50, 50, "")
SetGadgetFont(#MR, FontID1)
ButtonGadget(#UL, 10, 130, 50, 50, "")
SetGadgetFont(#UL, FontID1)
ButtonGadget(#UM, 70, 130, 50, 50, "")
SetGadgetFont(#UM, FontID1)
ButtonGadget(#UR, 130, 130, 50, 50, "")
SetGadgetFont(#UR, FontID1)
ButtonGadget(#Neustart, 10, 220, 80, 30, "Neues Spiel")
ButtonGadget(#Spielende, 100, 220, 80, 30, "Spiel Beenden")
TextGadget(#NAchricht, 10, 190, 170, 20, "", #PB_Text_Center)
SetGadgetFont(#NAchricht, FontID2)
EndIf
EndIf
EndProcedure
Open_Window_0()
SetGadgetText(#Nachricht,"X ist dran")
Repeat
Event = WaitWindowEvent()
If OL.l > 0 And OM.l > 0 And ORR.l > 0 And ML.l > 0 And MM.l > 0 And MR.l > 0 And UL.l > 0 And UM.l > 0 And UR.l > 0
SetGadgetText(#Nachricht,"keiner hat gewonnen")
EndIf
If OL.l = 1 And OM.l = 1 And ORR.l = 1
SetGadgetText(#NAchricht,"O gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf ML.l = 1 And MM.l = 1 And MR.l = 1
SetGadgetText(#NAchricht,"O gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf UL.l = 1 And UM.l = 1 And UR.l = 1
SetGadgetText(#NAchricht,"O gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf OL.l = 1 And ML.l = 1 And UL.l = 1
SetGadgetText(#NAchricht,"O gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf OM.l = 1 And MM.l = 1 And UM.l = 1
SetGadgetText(#NAchricht,"O gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf ORR.l= 1 And MR.l = 1 And UR.l = 1
SetGadgetText(#NAchricht,"O gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf OL.l = 1 And MM.l = 1 And UR.l = 1
SetGadgetText(#NAchricht,"O gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf ORR.l= 1 And MM.l = 1 And UL.l = 1
SetGadgetText(#NAchricht,"O gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
EndIf
If OL.l = 2 And OM.l = 2 And ORR.l = 2
SetGadgetText(#NAchricht,"X gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf ML.l = 2 And MM.l = 2 And MR.l = 2
SetGadgetText(#NAchricht,"X gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf UL.l = 2 And UM.l = 2 And UR.l = 2
SetGadgetText(#NAchricht,"X gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf OL.l = 2 And ML.l = 2 And UL.l = 2
SetGadgetText(#NAchricht,"X gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf OM.l = 2 And MM.l = 2 And UM.l = 2
SetGadgetText(#NAchricht,"X gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf ORR.l= 2 And MR.l = 2 And UR.l = 2
SetGadgetText(#NAchricht,"X gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf OL.l = 2 And MM.l = 2 And UR.l = 2
SetGadgetText(#NAchricht,"X gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
ElseIf ORR.l= 2 And MM.l = 2 And UL.l = 2
SetGadgetText(#NAchricht,"X gewinnt")
DisableGadget(#OL,1) : DisableGadget(#OM,1) : DisableGadget(#OR,1) : DisableGadget(#ML,1) : DisableGadget(#MM,1) : DisableGadget(#MR,1) : DisableGadget(#UL,1) : DisableGadget(#UM,1) : DisableGadget(#UR,1)
EndIf
If Event = #PB_EventCloseWindow
Quit = 1
ElseIf Event = #PB_Event_Gadget
Select EventGadgetID()
Case #OL
DisableGadget(#OL, 1)
If Pl.l = 0
SetGadgetText(#OL,"X")
OL.l = 2
Pl.l = 1
SetGadgetText(#Nachricht,"O ist dran")
ElseIf PL.l = 1
SetGadgetText(#OL,"O")
OL.l = 1
Pl.l = 0
SetGadgetText(#Nachricht,"X ist dran")
EndIf
Case #OM
DisableGadget(#OM, 1)
If Pl.l = 0
SetGadgetText(#OM,"X")
OM.l = 2
Pl.l = 1
SetGadgetText(#Nachricht,"O ist dran")
ElseIf PL.l = 1
SetGadgetText(#OM,"O")
OM.l = 1
Pl.l = 0
SetGadgetText(#Nachricht,"X ist dran")
EndIf
Case #OR
DisableGadget(#OR, 1)
If Pl.l = 0
SetGadgetText(#OR,"X")
ORR.l = 2
Pl.l = 1
SetGadgetText(#Nachricht,"O ist dran")
ElseIf PL.l = 1
SetGadgetText(#OR,"O")
ORR.l = 1
Pl.l = 0
SetGadgetText(#Nachricht,"X ist dran")
EndIf
Case #ML
DisableGadget(#ML, 1)
If Pl.l = 0
SetGadgetText(#ML,"X")
ML.l = 2
Pl.l = 1
SetGadgetText(#Nachricht,"O ist dran")
ElseIf PL.l = 1
SetGadgetText(#ML,"O")
ML.l = 1
Pl.l = 0
SetGadgetText(#Nachricht,"X ist dran")
EndIf
Case #MM
DisableGadget(#MM, 1)
If Pl.l = 0
SetGadgetText(#MM,"X")
MM.l = 2
Pl.l = 1
SetGadgetText(#Nachricht,"O ist dran")
ElseIf PL.l = 1
SetGadgetText(#MM,"O")
MM.l = 1
Pl.l = 0
SetGadgetText(#Nachricht,"X ist dran")
EndIf
Case #MR
DisableGadget(#MR, 1)
If Pl.l = 0
SetGadgetText(#MR,"X")
MR.l = 2
Pl.l = 1
SetGadgetText(#Nachricht,"O ist dran")
ElseIf PL.l = 1
SetGadgetText(#MR,"O")
MR.l = 1
Pl.l = 0
SetGadgetText(#Nachricht,"X ist dran")
EndIf
Case #UL
DisableGadget(#UL, 1)
If Pl.l = 0
SetGadgetText(#UL,"X")
UL.l = 2
Pl.l = 1
SetGadgetText(#Nachricht,"O ist dran")
ElseIf PL.l = 1
SetGadgetText(#UL,"O")
UL.l = 1
Pl.l = 0
SetGadgetText(#Nachricht,"X ist dran")
EndIf
Case #UM
DisableGadget(#UM, 1)
If Pl.l = 0
SetGadgetText(#UM,"X")
UM.l = 2
Pl.l = 1
SetGadgetText(#Nachricht,"O ist dran")
ElseIf PL.l = 1
SetGadgetText(#UM,"O")
UM.l = 1
Pl.l = 0
SetGadgetText(#Nachricht,"X ist dran")
EndIf
Case #UR
DisableGadget(#UR, 1)
If Pl.l = 0
SetGadgetText(#UR,"X")
UR.l = 2
Pl.l = 1
SetGadgetText(#Nachricht,"O ist dran")
ElseIf PL.l = 1
SetGadgetText(#UR,"O")
UR.l = 1
Pl.l = 0
SetGadgetText(#Nachricht,"X ist dran")
EndIf
Case #Spielende
End
Case #Neustart
DisableGadget(#OL,0) : SetGadgetText(#OL,"") : OL.l = 0
DisableGadget(#OM,0) : SetGadgetText(#OM,"") : OM.l = 0
DisableGadget(#OR,0) : SetGadgetText(#OR,"") : ORR.l = 0
DisableGadget(#ML,0) : SetGadgetText(#ML,"") : ML.l = 0
DisableGadget(#MM,0) : SetGadgetText(#MM,"") : MM.l = 0
DisableGadget(#MR,0) : SetGadgetText(#MR,"") : MR.l = 0
DisableGadget(#UL,0) : SetGadgetText(#UL,"") : UL.l = 0
DisableGadget(#UM,0) : SetGadgetText(#UM,"") : UM.l = 0
DisableGadget(#UR,0) : SetGadgetText(#UR,"") : UR.l = 0
SetGadgetText(#Nachricht,"X ist dran")
Pl.l = 0
EndSelect
EndIf
Until Quit
Wer draus nen 20 Zeiler macht bekommt Respect von mir!!!!!!!!!!!!!!!!!