Hallo Leute ich hoffe ihr könnt mir helfen.
Ich habe bisher versucht den Schwierigkeitsgrad einfach zu erstellen (Spiel Tic-Tac-Toe).
Nur leider funktioniert das gewinnen bei der Kombination oben rechts + mitte mitte + unten links nicht.
Wieso?
Ich weiß an diesem Script könnte bestimmt viel verbessert werden, aber es geht mir um den Lernprozess
Spoiler anzeigen
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Add_Constants=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
; Tic Tac Toe#include <ButtonConstants.au3>
Global $Feld1 = 0
Global $Feld2 = 0
Global $Feld3 = 0
Global $Feld4 = 0
Global $Feld5 = 0
Global $Feld6 = 0
Global $Feld7 = 0
Global $Feld8 = 0
Global $Feld9 = 0
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\Welcome.kxf
$Form1 = GUICreate("Welcome!", 615, 438, 192, 124)
$Label1 = GUICtrlCreateLabel("Tic Tac Toe gegen den Computer", 104, 16, 399, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Wähle eine Schwierigkeit:", 48, 72, 221, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Leicht", 160, 112, 241, 65)
$Button2 = GUICtrlCreateButton("Normal", 160, 184, 241, 73)
$Button3 = GUICtrlCreateButton("Unbesiegbar", 160, 264, 241, 73)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Koda_Einfach()
EndSwitch
WEnd
Func Koda_Einfach()
; Insert Koda Einfach hier
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=d:\daten\desktop\autoit\laptop\tic tac toe\einfach.kxf
$Form1_1 = GUICreate("Tic-Tac-Toe-Einfach", 616, 439, 192, 124)
$Label1 = GUICtrlCreateLabel("Einfach :-)", 56, 16, 89, 28)
GUICtrlSetFont($Label1, 14, 400, 0, "MS Sans Serif")
$Pic1 = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\Leer.jpg", 80, 56, 481, 353)
GUICtrlSetState($Pic1, $GUI_DISABLE)
Global $Button_1 = GUICtrlCreateButton("X setzen", 104, 64, 105, 89)
GUICtrlSetFont($Button_1, 14, 800, 0, "MS Sans Serif")
Global $Button_8 = GUICtrlCreateButton("X setzen", 254, 293, 105, 89)
GUICtrlSetFont($Button_8, 14, 800, 0, "MS Sans Serif")
Global $Button_2 = GUICtrlCreateButton("X setzen", 262, 61, 105, 89)
GUICtrlSetFont($Button_2, 14, 800, 0, "MS Sans Serif")
Global $Button_9 = GUICtrlCreateButton("X setzen", 430, 285, 105, 89)
GUICtrlSetFont($Button_9, 14, 800, 0, "MS Sans Serif")
Global $Button_5 = GUICtrlCreateButton("X setzen", 254, 181, 105, 89)
GUICtrlSetFont($Button_5, 14, 800, 0, "MS Sans Serif")
Global $Button_6 = GUICtrlCreateButton("X setzen", 430, 181, 105, 89)
GUICtrlSetFont($Button_6, 14, 800, 0, "MS Sans Serif")
Global $Button_4 = GUICtrlCreateButton("X setzen", 102, 181, 105, 89)
GUICtrlSetFont($Button_4, 14, 800, 0, "MS Sans Serif")
Global $Button_3 = GUICtrlCreateButton("X setzen", 430, 61, 105, 89)
GUICtrlSetFont($Button_3, 14, 800, 0, "MS Sans Serif")
Global $Button_7 = GUICtrlCreateButton("X setzen", 102, 293, 105, 89)
GUICtrlSetFont($Button_7, 14, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button_1
$x_oben_links = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\X.jpg", 104, 64, 105, 89)
GUICtrlSetState($Button_1, $GUI_HIDE)
$Feld1 = 1
PC_Zug_Einfach()
Case $Button_2
$x_oben_mitte = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\X.jpg", 248, 64, 129, 89)
GUICtrlSetState($Button_2, $GUI_HIDE)
$Feld2 = 1
PC_Zug_Einfach()
Case $Button_3
$x_oben_rechts = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\X.jpg", 432, 64, 113, 97)
GUICtrlSetState($Button_3, $GUI_HIDE)
$Feld3 = 1
PC_Zug_Einfach()
Case $Button_4
$x_mitte_links = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\X.jpg", 104, 184, 97, 81)
GUICtrlSetState($Button_4, $GUI_HIDE)
$Feld4 = 1
PC_Zug_Einfach()
Case $Button_5
$x_mitte_mitte = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\X.jpg", 256, 176, 121, 89)
GUICtrlSetState($Button_5, $GUI_HIDE)
$Feld5 = 1
PC_Zug_Einfach()
Case $Button_6
$x_mitte_rechts = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\X.jpg", 424, 184, 113, 81)
GUICtrlSetState($Button_6, $GUI_HIDE)
$Feld6 = 1
PC_Zug_Einfach()
Case $Button_7
$x_unten_links = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\X.jpg", 104, 288, 105, 81)
GUICtrlSetState($Button_7, $GUI_HIDE)
$Feld7 = 1
PC_Zug_Einfach()
Case $Button_8
$x_unten_mitte = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\X.jpg", 256, 288, 97, 81)
GUICtrlSetState($Button_8, $GUI_HIDE)
$Feld8 = 1
PC_Zug_Einfach()
Case $Button_9
$x_unten_rechts = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\X.jpg", 424, 288, 105, 81)
GUICtrlSetState($Button_9, $GUI_HIDE)
$Feld9 = 1
PC_Zug_Einfach()
EndSwitch
WEnd
; End Koda Einfach hier
EndFunc ;==>Koda_Einfach
Func PC_Zug_Einfach()
[/autoit] [autoit][/autoit] [autoit]If ($Feld1 = 1 And $Feld2 = 1 And $Feld3 = 1) Or ($Feld1 = 1 And $Feld4 = 1 And $Feld7 = 1) Or ($Feld4 = 1 And $Feld5 = 1 And $Feld6 = 1) Or ($Feld7 = 1 And $Feld8 = 1 And $Feld9 = 1) Or ($Feld2 = 1 And $Feld5 = 1 And $Feld8 = 1) Or ($Feld3 = 1 And $Feld6 = 1 And $Feld9 = 1) Or ($Feld1 = 1 And $Feld5 = 1 And $Feld9 = 1) Or ($Feld3 = 1 And $Feld5 = 1 And $Feld7 = 1) Then
MsgBox(0, "Sieg", "Du hast gewonnen herzlichen Glückwunsch!")
Run(@ScriptDir & "\0.8.exe")
Exit
Else
If ($Feld1 = 1 Or $Feld1 = 2) And ($Feld2 = 1 Or $Feld2 = 2) And ($Feld3 = 1 Or $Feld3 = 2) And ($Feld4 = 1 Or $Feld4 = 2) And ($Feld5 = 1 Or $Feld5 = 2) And ($Feld6 = 1 Or $Feld6 = 2) And ($Feld7 = 1 Or $Feld7 = 2) And ($Feld8 = 1 Or $Feld8 = 2) And ($Feld9 = 1 Or $Feld9 = 2) Then
MsgBox(0, "Unentschieden", "Unentschieden!")
Run(@ScriptDir & "\0.8.exe")
Exit
EndIf
$nummer = Random(1, 10, 1)
If $nummer = 1 And $Feld1 <> 1 And $Feld1 <> 2 Then
$o_oben_links = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\Kreis.jpg", 104, 64, 97, 89)
$Feld1 = 2
GUICtrlSetState($Button_1, $GUI_HIDE)
ElseIf $nummer = 2 And $Feld2 <> 1 And $Feld2 <> 2 Then
$o_oben_mitte = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\Kreis.jpg", 248, 64, 121, 89)
$Feld2 = 2
GUICtrlSetState($Button_2, $GUI_HIDE)
ElseIf $nummer = 3 And 1 <> $Feld3 And $Feld3 <> 2 Then
$o_oben_rechts = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\Kreis.jpg", 440, 64, 97, 89)
$Feld3 = 2
GUICtrlSetState($Button_3, $GUI_HIDE)
ElseIf $nummer = 4 And 1 <> $Feld4 And $Feld4 <> 2 Then
$o_mitte_links = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\Kreis.jpg", 112, 184, 89, 81)
$Feld4 = 2
GUICtrlSetState($Button_4, $GUI_HIDE)
ElseIf $nummer = 5 And 1 <> $Feld5 And $Feld5 <> 2 Then
$o_mitte_mitte = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\Kreis.jpg", 264, 184, 97, 81)
$Feld5 = 2
GUICtrlSetState($Button_5, $GUI_HIDE)
ElseIf $nummer = 6 And 1 <> $Feld6 And $Feld6 <> 2 Then
$o_mitte_rechts = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\Kreis.jpg", 432, 184, 97, 81)
$Feld6 = 2
GUICtrlSetState($Button_6, $GUI_HIDE)
ElseIf $nummer = 7 And 1 <> $Feld7 And $Feld7 <> 2 Then
$o_unten_links = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\Kreis.jpg", 112, 296, 89, 73)
$Feld7 = 2
GUICtrlSetState($Button_7, $GUI_HIDE)
ElseIf $nummer = 8 And $Feld8 <> 1 And $Feld8 <> 2 Then
$o_unten_mitte = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\Kreis.jpg", 264, 288, 89, 89)
$Feld8 = 2
GUICtrlSetState($Button_8, $GUI_HIDE)
ElseIf $nummer = 9 And $Feld9 <> 1 And $Feld9 <> 2 Then
$o_unten_rechts = GUICtrlCreatePic("D:\Daten\Desktop\AutoIt\Laptop\Tic Tac Toe\Kreis.jpg", 432, 288, 97, 81)
$Feld9 = 2
GUICtrlSetState($Button_9, $GUI_HIDE)
Else
PC_Zug_Einfach()
EndIf
If ($Feld1 = 2 And $Feld2 = 2 And $Feld3 = 2) Or ($Feld1 = 2 And $Feld4 = 2 And $Feld7 = 2) Or ($Feld4 = 2 And $Feld5 = 2 And $Feld6 = 2) Or ($Feld7 = 2 And $Feld8 = 2 And $Feld9 = 2) Or ($Feld2 = 2 And $Feld5 = 2 And $Feld8 = 2) Or ($Feld3 = 2 And $Feld6 = 2 And $Feld9 = 2) Or ($Feld1 = 2 And $Feld5 = 2 And $Feld9 = 2) Or ($Feld3 = 1 And $Feld5 = 1 And $Feld7 = 1) Then
MsgBox(0, "Verloren", "Du hast leider verloren")
Run(@ScriptDir & "\0.8.exe")
Exit
EndIf
EndIf
EndFunc ;==>PC_Zug_Einfach
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit]