Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <Misc.au3>
Global $key, $win = -1, $lost = 0
Dim $labels[1]
Global $string = "azertyuiopqsdfghjklmwxcvbn"
;======REGLAGES============
Global $vitesse_creation_lettres = 1000
Global $vitesse_descente = 500
;===========================
$gui = GUICreate("My GUI", -1, -1, 400, 400)
GUISetBkColor(0xffffff)
GUISetFont(12, 600, 0, "Tahoma")
GUICtrlCreateLabel ("", 0, 330, 400, 4)
GUICtrlSetBkColor(-1, 0xff0000)
GUICtrlCreateLabel ("SCORE", 20, 340, 80, 20)
GUICtrlCreateLabel ("gagnés :", 120, 340, 70, 20)
$winlabel = GUICtrlCreateLabel ("", 200, 340, 30, 20)
GUICtrlCreateLabel ("perdus :", 260, 340, 70, 20)
$lostlabel = GUICtrlCreateLabel ("0", 340, 340, 30, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState()
New_Lettre()
AdLibRegister("New_Lettre", $vitesse_creation_lettres)
$begin = TimerInit()
While 1
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"
If NOT StringInStr($string, $key) Then
For $i = 0 to UBound($labels)-2
If GuiCtrlRead($labels[$i]) = $key Then
GuiCtrlDelete($labels[$i])
_ArrayDelete($labels, $i)
$string &= $key
$win += 1
GuiCtrlSetData($winlabel, $win)
EndIf
Next
EndIf
If TimerDiff($begin)>$vitesse_descente Then
For $i = 0 to UBound($labels)-2
$pos = ControlGetPos ($gui, "", $labels[$i])
If $pos[1]>260 Then
GUICtrlSetBkColor($labels[$i], 0xff9999)
EndIf
If $pos[1]>280 Then
GUICtrlSetBkColor($labels[$i], 0xff2222)
EndIf
If $pos[1]>290 Then
$string &= GuiCtrlRead($labels[$i])
GUICtrlSetBkColor($labels[$i], 0xff0000)
GuiCtrlDelete($labels[$i])
_ArrayDelete($labels, $i)
$lost += 1
GuiCtrlSetData($lostlabel, $lost)
Else
GUICtrlSetPos($labels[$i], $pos[0], $pos[1]+20)
EndIf
Next
$begin = TimerInit()
EndIf
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
Func New_Lettre()
$char = StringSplit($string, "")
$lettre = $char[Random(1, $char[0]-1, 1)]
$xpos = Random(1, 18, 1)*20
$new = GUICtrlCreateLabel ($lettre, $xpos, 10, 20, 20, 1) ; $SS_CENTER = 0x1
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
_ArrayAdd($labels, $new)
$string = StringReplace($string, $lettre, "")
EndFunc