Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Jeu de Michaël", 787, 489, 497, 347)
GUISetFont(8, 400, 0, "Copperplate Gothic Bold")
Global $Label1 = GUICtrlCreateLabel("Le jeu du Plus ou du Moins", 124, 16, 539, 43)
GUICtrlSetFont(-1, 22, 800, 0, "Ravie")
Global $Input1 = GUICtrlCreateInput("", 320, 80, 113, 21)
Global $Label2 = GUICtrlCreateLabel("Chiffre le plus petit:", 104, 88, 155, 19)
GUICtrlSetFont(-1, 10, 400, 0, "Copperplate Gothic Bold")
Global $Label3 = GUICtrlCreateLabel("Chiffre le plus grand:", 104, 128, 167, 19)
GUICtrlSetFont(-1, 10, 400, 0, "Copperplate Gothic Bold")
Global $Input2 = GUICtrlCreateInput("", 320, 120, 113, 21)
Global $Label4 = GUICtrlCreateLabel("Nombre de coup(s) Maximum:", 104, 168, 207, 19)
GUICtrlSetFont(-1, 10, 400, 0, "Copperplate Gothic Bold")
Global $Input3 = GUICtrlCreateInput("", 320, 160, 113, 21)
Global $Button1 = GUICtrlCreateButton("Valider", 500, 112, 113, 41, $WS_GROUP)
Global $Label5 = GUICtrlCreateLabel("", 68, 248, 236, 124)
GUICtrlSetFont(-1, 12, 400, 0, "Copperplate Gothic Bold")
GUICtrlSetFont(-1, 10, 400, 0, "Copperplate Gothic Bold")
Global $Progress1 = GUICtrlCreateProgress(48, 416, 705, 57)
Global $Button2 = GUICtrlCreateButton("Valider", 500, 112, 113, 41, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$chiffrePremier = GUICtrlRead($Input1)
$chiffreDeuxieme = GUICtrlRead($Input2)
$maximum = GUICtrlRead($Input3)
Global $chiffreH = Random($chiffrePremier, $chiffreDeuxieme, 1)
GUICtrlSetData($Progress1, 25)
Sleep(500)
GUICtrlSetData($Label5, "C'est bon, essayé de trouver le nombre mystère maintenant!")
Global $i = 1
Global $max = 0
GUICtrlDelete($Input1)
GUICtrlDelete($Input2)
GUICtrlDelete($Input3)
GUICtrlDelete($Button1)
Global $Label7 = GUICtrlCreateLabel($chiffrePremier, 320, 80, 400, 21)
GUICtrlSetFont(-1, 16, 400, 0, "Copperplate Gothic Bold")
Global $Label8 = GUICtrlCreateLabel($chiffreDeuxieme, 320, 120, 400, 21)
GUICtrlSetFont(-1, 16, 400, 0, "Copperplate Gothic Bold")
Global $Label9 = GUICtrlCreateLabel($maximum, 320, 160, 400, 21)
GUICtrlSetFont(-1, 16, 400, 0, "Copperplate Gothic Bold")
Global $Label6 = GUICtrlCreateLabel("Nombre Mystère:", 392, 248, 129, 19)
Global $Input4 = GUICtrlCreateInput("", 544, 248, 113, 21)
Case $Button2
$reponse = GUICtrlRead($Input4)
$reponse = Number($reponse)
If ($reponse > $chiffreH) Then
GUICtrlSetData($Progress1, 60)
Sleep(500)
GUICtrlSetData($Label5, "Pas mal... mais c'est un peu moins !" & @CRLF & "Nombre tenté : " & $reponse)
ElseIf ($reponse < $chiffreH) Then
GUICtrlSetData($Progress1, 60)
Sleep(500)
GUICtrlSetData($Label5, "Pas mal... mais c'est un peu plus !" & @CRLF & "Nombre tenté : " & $reponse)
ElseIf ($reponse = $chiffreH) Then
Sleep(500)
GUICtrlSetData($Progress1, 100)
GUICtrlSetData($Label5, "Vous avez réussi ! Extraordinaire ! Bravo ! Bip Bip Bip Fin du programme.")
GUICtrlDelete($Button2)
GUICtrlDelete($Input4)
Global $Label10 = GUICtrlCreateLabel($reponse, 544, 245, 113, 21)
GUICtrlSetFont(-1, 16, 400, 0, "Copperplate Gothic Bold")
Global $Button3 = GUICtrlCreateButton("Réessayer", 500, 112, 113, 41, $WS_GROUP)
Case $Button3
GUi
EndIf
$i = $i + 1
$max = $max + 1
If $maximum = $max - 1 Then
Sleep(500)
GUICtrlSetData($Label5, " Quel dommage vous avez fait " & $i - 1 & " coup(s) alors que vous aviez prévu " & $maximum & " coup(s), mais essayez quand même de trouver le nombre mystère!!!")
EndIf
EndSwitch
WEnd