Code : Tout sélectionner
;===Includes===
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <Misc.au3>
;===Déclaration des variables===
Global $Key, $Reussis = -1, $Echoues = 0
Dim $Labels[1]
Global $String = "azertyuiopqsdfghjklmwxcvbn"
;==Réglages==
Global $VitesseCreationLettres = 500 ;Facile=1200 Moyen=800 Difficile=400 Expert=500
Global $VitesseDescente = 200 ;Facile=800 Moyen=600 Difficile=400 Expert=200
;===GUI===
#Region ### START Koda GUI section ### Form=
;=Fenêtre=
$GUI = GUICreate("TouchKeyPro 1", 391, 410, 638, 233)
;=Titre=
$LabelTitre = GUICtrlCreateLabel("Touch Key Pro 1", 8, 8, 378, 57)
GUICtrlSetFont(-1, 36, 800, 0, "OptimusPrinceps")
;=Barres de jeu=
$BarreBas = GUICtrlCreateLabel("", 0, 306, 390, 4)
GUICtrlSetBkColor(-1, 0xFF0000)
$BarreHaut = GUICtrlCreateLabel("", 0, 66, 390, 4)
GUICtrlSetBkColor(-1, 0xFF0000)
;=Groupe Score=
$GroupScore = GUICtrlCreateGroup("Score", 8, 320, 113, 65)
GUICtrlCreateLabel("Coups Réussis", 16, 336, 74, 17)
GUICtrlSetColor(-1, 0x008000)
$CoupsReussis = GUICtrlCreateLabel("", 95, 336, 20, 17)
GUICtrlCreateLabel("Coups Echoués", 16, 360, 79, 17)
GUICtrlSetColor(-1, 0xFF0000)
$CoupsEchoues = GUICtrlCreateLabel("0", 95, 360, 20, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;=Groupe Etat=
$GroupEtat = GUICtrlCreateGroup("Etat", 120, 320, 129, 65)
$LabelEtat = GUICtrlCreateLabel("Jeu en cours", 128, 336, 112, 17)
GUICtrlCreateLabel("Niveau", 128, 360, 38, 17)
$Niveau = GUICtrlCreateLabel("Facile", 184, 360, 32, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;=Groupe Vitesse=
$GroupVitesse = GUICtrlCreateGroup("Vitesse", 248, 320, 137, 65)
GUICtrlCreateLabel("Vitesse de jeu", 256, 336, 70, 17)
$InfoVitesseJeu = GUICtrlCreateLabel("Modérée", 336, 336, 46, 17)
GUICtrlCreateLabel("Création lettres", 256, 360, 74, 17)
$InfoCreationLettre = GUICtrlCreateLabel("Modérée", 336, 360, 46, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;=Menu=
$MenubarFichier = GUICtrlCreateMenu("Fichier")
$FilePause = GUICtrlCreateMenuItem("Pause (F1)", $MenubarFichier)
$FileOptions = GUICtrlCreateMenuItem("Options (F11)", $MenubarFichier)
$FileQuitter = GUICtrlCreateMenuItem("Quitter (F12)", $MenubarFichier)
;=Afficher=
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;=Création Lettres=
NewLettre()
AdLibRegister("NewLettre", $VitesseCreationLettres)
$Begin = TimerInit()
;===Boucle Principale===
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_Exit()
;=MenubarFichier=
Case $FilePause
_Pause()
Case $FileOptions
_Options()
Case $FileQuitter
_Exit()
EndSwitch
;=Gestion de l'appuie sur touche=
If _IsPressed("41") Then $Key = "a"
If _IsPressed("42") Then $Key = "b"
If _IsPressed("43") Then $Key = "c"
If _IsPressed("44") Then $Key = "d"
If _IsPressed("45") Then $Key = "e"
If _IsPressed("46") Then $Key = "f"
If _IsPressed("47") Then $Key = "g"
If _IsPressed("48") Then $Key = "h"
If _IsPressed("49") Then $Key = "i"
If _IsPressed("4A") Then $Key = "j"
If _IsPressed("4B") Then $Key = "k"
If _IsPressed("4C") Then $Key = "l"
If _IsPressed("4D") Then $Key = "m"
If _IsPressed("4E") Then $Key = "n"
If _IsPressed("4F") Then $Key = "o"
If _IsPressed("50") Then $Key = "p"
If _IsPressed("51") Then $Key = "q"
If _IsPressed("52") Then $Key = "r"
If _IsPressed("53") Then $Key = "s"
If _IsPressed("54") Then $Key = "t"
If _IsPressed("55") Then $Key = "u"
If _IsPressed("56") Then $Key = "v"
If _IsPressed("57") Then $Key = "w"
If _IsPressed("58") Then $Key = "x"
If _IsPressed("59") Then $Key = "y"
If _IsPressed("5A") Then $Key = "z"
;=Gestion des coups réussis=
If NOT StringInStr($String, $Key) Then
For $i = 0 to UBound($Labels)-2
If GuiCtrlRead($Labels[$i]) = $Key Then
_Green()
AdlibRegister("_Red", 1000)
GuiCtrlDelete($Labels[$i])
_ArrayDelete($Labels, $i)
$String &= $Key
$Reussis += 1
GuiCtrlSetData($CoupsReussis, $Reussis)
EndIf
Next
EndIf
;=Déplacement des lettres=
If TimerDiff($Begin)>$VitesseDescente Then
For $i = 0 to UBound($Labels)-2
$Pos = ControlGetPos ($GUI, "", $Labels[$i])
If $Pos[1]>236 Then
GUICtrlSetBkColor($Labels[$i], 0xff9999)
EndIf
If $Pos[1]>256 Then
GUICtrlSetBkColor($Labels[$i], 0xff2222)
EndIf
If $Pos[1]>280 Then
$String &= GuiCtrlRead($Labels[$i])
GUICtrlSetBkColor($Labels[$i], 0xff0000)
GuiCtrlDelete($Labels[$i])
_ArrayDelete($Labels, $i)
$Echoues += 1
GuiCtrlSetData($CoupsEchoues, $Echoues)
Else
GUICtrlSetPos($Labels[$i], $Pos[0], $Pos[1]+20)
EndIf
Next
$Begin = TimerInit()
EndIf
WEnd
Func _Green()
GUICtrlSetBkColor($BarreBas, 0x00FF00)
GUICtrlSetBkColor($BarreHaut, 0x00FF00)
AdlibRegister("_Red", 1000)
EndFunc
Func _Red()
GUICtrlSetColor($BarreBas, 0xFF0000)
GUICtrlSetColor($BarreHaut, 0xFF0000)
AdlibUnRegister("_Red")
EndFunc
;===Fonction NewLettre()
Func NewLettre()
$Char = StringSplit($String, "")
$Lettre = $Char[Random(1, $Char[0]-1, 1)]
$xPos = Random(1, 18, 1)*20
$New = GUICtrlCreateLabel ($Lettre, $xPos, 68, 20, 20, 1)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
_ArrayAdd($Labels, $New)
$String = StringReplace($String, $Lettre, "")
EndFunc
;===Fonction HotKeys===
;===Fonction EXIT F12===
Func _Exit()
Exit
EndFunc
;===Fonction PAUSE F1===
Func _Pause()
;==Pause Flood==
If GUICtrlRead($LabelEtat) = "Jeu en cours" Then
While 1
Sleep(100)
GUICtrlSetData($LabelEtat, "Jeu en pause")
WEnd
ElseIf GUICtrlRead($LabelEtat) = "Jeu en pause" Then
GUICtrlSetData($LabelEtatFlood, "Jeu en cours")
Sleep(100)
EndIf
EndFunc