J'essaye a faire un jeu du pendu, seulement, plusieurs choses ne fonctionnent pas et je n'arrive pas a les résoudres.
Voila mon
Voici la liste de mot
Liste de mot.txt- (15.13 Kio) Téléchargé 77 fois
► Afficher le texte
Code : Tout sélectionner
#include <GDIPlus.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#region ### START Koda GUI section ### Form=c:\documents and settings\veron matthieu\bureau\autoit\pendu.kxf
$mot = 0
$ligne = ""
$taille = 0
$total = 11
$Final = ""
$result = ""
$result2 = ""
$lettre = 0
$resultdeja = ""
$Input1 = ""
$group = ""
$lettre = ""
$Boucle = ""
$rien = 0
$inconnues = ""
$Graphic1 = ""
$nombre = ""
$dessin = 0
$lettreTotale = ""
;;;;;;;;;;;;;;;;;;;
$ligne = Floor(Random(1, 1417))
$mot = FileReadLine("Liste de mot.txt", $ligne)
MsgBox(0, "mot", "" & $mot & "")
$taille = StringLen($mot) - 3
;~ MsgBox(0, "Taille du mot","" & $taille & "")
$inconnues = Tirets($taille)
;;;;;;;;;;;;;;;;;;;;
$Jeu = GUICreate("Jeu'broms", 633, 447, 192, 124)
GUISetFont(10, 800, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Le jeu du Pendu", 85, 13, 462, 52)
GUICtrlSetFont(-1, 28, 400, 0, "Earth")
$Label2 = GUICtrlCreateLabel("Entrez une lettre", 8, 136, 206, 39)
GUICtrlSetFont(-1, 18, 800, 0, "Comic Sans MS")
$input = GUICtrlCreateInput("", 240, 144, 161, 24)
$Valider = GUICtrlCreateButton("Valider", 424, 136, 203, 33, $WS_GROUP)
GUICtrlSetFont(-1, 14, 400, 0, "Comic Sans MS")
$Group1 = GUICtrlCreateGroup("Lettre utilisées", 416, 200, 169, 121)
GUISetState(@SW_SHOW)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label14 = GUICtrlCreateLabel($inconnues, 408, 376, 220, 20)
$Graphic1 = GUICtrlCreateGraphic(8, 176, 393, 257)
GUICtrlSetBkColor(-1, 0xece9d8)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Valider
$lettreTotale = GUICtrlRead($input)
$lettre = StringLeft($lettreTotale, 1)
;~ MsgBox(0,"lettre saisi",$lettre)
$result = StringInStr($mot, $lettre)
$resultdeja = StringInStr($inconnues, $lettre)
;~ MsgBox(0,"position de la lettre saisi",$result)
If ($result <> 0 And $resultdeja = 0) Then ; si on la trouve
$nombre = $nombre + 1
$inconnues = StringReplace($inconnues, $result, $lettre, 1) ; on remplace le $result ième tiret par la lettre saisie
$result2 = StringInStr($mot, $lettre, 0, 1, $result + 1)
While $result2 <> 0
$inconnues = StringReplace($inconnues, $result2, $lettre, 1) ; on remplace le $result ième tiret par la lettre saisie
$result2 = StringInStr($mot, $lettre, 0, 1, $result2 + 1)
$nombre = $nombre + 1
WEnd
EndIf
;~ While $total <> 0 and $lettre <> $taille
$Final = $Final & "_"
;~ ;~ MsgBox(0, "","" & $Final & "")
If $result = 0 Then $dessin = $dessin + 1
;~ MsgBox(0,"Dessin",$dessin)
If $Boucle = 0 And $result = 0 Then
$Label3 = GUICtrlCreateLabel($lettre, 424, 224, 20, 20)
GUICtrlSetColor(-1, 0xFF0000)
EndIf
If $Boucle = 1 And $result = 0 Then
$Label4 = GUICtrlCreateLabel($lettre, 456, 224, 20, 20)
GUICtrlSetColor(-1, 0xFF0000)
EndIf
If $Boucle = 2 And $result = 0 Then
$Label5 = GUICtrlCreateLabel($lettre, 488, 224, 20, 20)
GUICtrlSetColor(-1, 0xFF0000)
EndIf
If $Boucle = 3 And $result = 0 Then
$Label6 = GUICtrlCreateLabel($lettre, 520, 224, 20, 20)
GUICtrlSetColor(-1, 0xFF0000)
EndIf
If $Boucle = 4 And $result = 0 Then
$Label7 = GUICtrlCreateLabel($lettre, 552, 224, 20, 20)
GUICtrlSetColor(-1, 0xFF0000)
EndIf
If $Boucle = 5 And $result = 0 Then
$Label8 = GUICtrlCreateLabel($lettre, 424, 256, 20, 20)
GUICtrlSetColor(-1, 0xFF0000)
EndIf
If $Boucle = 6 And $result = 0 Then
$Label9 = GUICtrlCreateLabel($lettre, 456, 256, 20, 20)
GUICtrlSetColor(-1, 0xFF0000)
EndIf
If $Boucle = 7 And $result = 0 Then
$Label10 = GUICtrlCreateLabel($lettre, 488, 256, 20, 20)
GUICtrlSetColor(-1, 0xFF0000)
EndIf
If $Boucle = 8 And $result = 0 Then
$Label11 = GUICtrlCreateLabel($lettre, 520, 256, 20, 20)
GUICtrlSetColor(-1, 0xFF0000)
EndIf
If $Boucle = 9 And $result = 0 Then
$Label12 = GUICtrlCreateLabel($lettre, 552, 256, 20, 20)
GUICtrlSetColor(-1, 0xFF0000)
EndIf
If $Boucle = 10 And $result = 0 Then
$Label13 = GUICtrlCreateLabel($lettre, 424, 288, 20, 20)
GUICtrlSetColor(-1, 0xFF0000)
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;,
If $Boucle = 0 And $result <> 0 Then
$Label3 = GUICtrlCreateLabel($lettre, 424, 224, 20, 20)
GUICtrlSetColor(-1, 0x0000FF)
EndIf
If $Boucle = 1 And $result <> 0 Then
$Label4 = GUICtrlCreateLabel($lettre, 456, 224, 20, 20)
GUICtrlSetColor(-1, 0x0000FF)
EndIf
If $Boucle = 2 And $result <> 0 Then
$Label5 = GUICtrlCreateLabel($lettre, 488, 224, 20, 20)
GUICtrlSetColor(-1, 0x0000FF)
EndIf
If $Boucle = 3 And $result <> 0 Then
$Label6 = GUICtrlCreateLabel($lettre, 520, 224, 20, 20)
GUICtrlSetColor(-1, 0x0000FF)
EndIf
If $Boucle = 4 And $result <> 0 Then
$Label7 = GUICtrlCreateLabel($lettre, 552, 224, 20, 20)
GUICtrlSetColor(-1, 0x0000FF)
EndIf
If $Boucle = 5 And $result <> 0 Then
$Label8 = GUICtrlCreateLabel($lettre, 424, 256, 20, 20)
GUICtrlSetColor(-1, 0x0000FF)
EndIf
If $Boucle = 6 And $result <> 0 Then
$Label9 = GUICtrlCreateLabel($lettre, 456, 256, 20, 20)
GUICtrlSetColor(-1, 0x0000FF)
EndIf
If $Boucle = 7 And $result <> 0 Then
$Label10 = GUICtrlCreateLabel($lettre, 488, 256, 20, 20)
GUICtrlSetColor(-1, 0x0000FF)
EndIf
If $Boucle = 8 And $result <> 0 Then
$Label11 = GUICtrlCreateLabel($lettre, 520, 256, 20, 20)
GUICtrlSetColor(-1, 0x0000FF)
EndIf
If $Boucle = 9 And $result <> 0 Then
$Label12 = GUICtrlCreateLabel($lettre, 552, 256, 20, 20)
GUICtrlSetColor(-1, 0x0000FF)
EndIf
If $Boucle = 10 And $result <> 0 Then
$Label13 = GUICtrlCreateLabel($lettre, 424, 288, 20, 20)
GUICtrlSetColor(-1, 0x0000FF)
EndIf
$Boucle = $Boucle + 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If $dessin = 1 Then
$Graphic1 = GUICtrlCreateGraphic(8, 176, 393, 257)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 30, 230)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 150, 230)
EndIf
If $dessin = 2 Then
$Graphic1 = GUICtrlCreateGraphic(8, 176, 393, 257)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 30, 230)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 150, 230)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 90, 230)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 90, 30)
EndIf
If $dessin = 3 Then
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 130, 30)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 90, 60)
EndIf
If $dessin = 4 Then
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 90, 30)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 300, 30)
EndIf
If $dessin = 5 Then
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 300, 30)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 300, 50)
EndIf
If $dessin = 6 Then
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 277.5, 50, 45, 50)
EndIf
If $dessin = 7 Then
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 300, 100)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 300, 160)
EndIf
If $dessin = 8 Then
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 300, 100)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 260, 140)
EndIf
If $dessin = 9 Then
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 300, 100)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 340, 140)
EndIf
If $dessin = 10 Then
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 300, 160)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 260, 200)
EndIf
If $dessin = 11 Then
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xfff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 300, 160)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 340, 200)
EndIf
$Label14 = GUICtrlCreateLabel($inconnues, 408, 376, 220, 20)
$rien = GUICtrlSetData($input, "")
if ($result <> 0 And $Boucle = $taille) Then MsgBox(0, "", "Bravo tu as trouvé le mot")
if ($result <> 0 And $Boucle = $taille) Then ProcessClose("AutoIt3.exe")
EndSwitch
WEnd
;;;;;;;;;
Func Tirets($value)
Local $ret = ""
For $i = 1 To $value
$ret = $ret & '.'
Next
Return $ret
EndFunc ;==>TiretsSi le mot fait 5 lettres et que je tape 5 fois une lettre bonne, sa me fais quand meme gagner.
Mon dessin du pendu ne sâffiche que si je reduit et ré affiche la GUI.
Possibilité de bloqué un INPUT a 1 seul lettre ?
Si vous voyer d'autre probleme je veux bien le savoir x)
Merci
Bromy






