Moin Moin,
ich habe letztens mich mit GDI+ beschäftigt und mein erstes GDI+ Werk erstellt. Es ist eine art Spiel oder so, keine ahnung^^
Damit kann man die Reaktionsfähigkeit von einem testen. Wenn man binnen 500 Millisekunden ab dem erscheinen eines Viereckes keine Pfeiltaste gedrückt hat, so hat man verloren.
V1.2:
- Neue schwierigkeitsstufe: HART
- Bug mit dem roten "Laserstrahl" behoben
- Vormenü
- Infos werden im Vormenü angezeigt
- verschiedene Geschwindigkeiten in unterschiedlichen Levels
CodeV1.2:
Spoiler anzeigen
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Misc.au3>
Global $aPoints[13][2],$bPoints[13][2], $hWnd, $hGraphic, $wPressed = 0, $gPressed = 0, $iX, $iY, $GO_lbl, $var
_GDIPlus_Startup()
$hWnd = GUICreate("Geschick", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetBkColor(0x343434)
Global $lbl_leicht = GUICtrlCreateLabel(" Leicht", @DesktopWidth / 2 - 200, 200, 400, 60)
GUICtrlSetFont(-1, 30, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0x000FF00)
Global $lbl_mittel = GUICtrlCreateLabel(" Mittel", @DesktopWidth / 2 - 200, 280, 400, 60)
GUICtrlSetFont(-1, 30, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0xFFFF00)
Global $lbl_schwer = GUICtrlCreateLabel(" Schwer", @DesktopWidth / 2 - 200, 360, 400, 60)
GUICtrlSetFont(-1, 30, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0xFF4600)
Global $lbl_hart = GUICtrlCreateLabel(" Hart", @DesktopWidth / 2 - 200, 440, 400, 60)
GUICtrlSetFont(-1, 30, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0xAA0000)
Global $lbl_beenden = GUICtrlCreateLabel(" Beenden", @DesktopWidth / 2 - 200, 520, 400, 60)
GUICtrlSetFont(-1, 30, 750,0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$lbl_info = GUICtrlCreateLabel("", @DesktopWidth / 2 + 250, 200, 400, 500)
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")
GUISetState()
while 1
$msg = GUIGetMsg()
$cPos = GUIGetCursorInfo()
Select
case $msg = $lbl_leicht
$schwierigkeit = "leicht"
ExitLoop
case $msg = $lbl_mittel
$schwierigkeit = "mittel"
ExitLoop
case $msg = $lbl_schwer
$schwierigkeit = "schwer"
ExitLoop
case $msg = $lbl_hart
$schwierigkeit = "hart"
ExitLoop
case $msg = $lbl_beenden
_exit_noob()
case $cPos[4] = $lbl_leicht And $var <> "leicht"
$info_msg = "INFOS:" & @CRLF & "Stufe: Leicht" & @CRLF & "Verloren nach - 10 - Fehltreffern" & @CRLF & "Gewonnen nach - 20 - Treffern" & @CRLF & "Maximaler Abstand zwischen Viereckgeneratrion: 2000 Millisekunden" & @CRLF & "Maximale Wartezeit: 1000 Millisekunden"
GUICtrlSetData($lbl_info, $info_msg)
$var = "leicht"
case $cPos[4] = $lbl_mittel And $var <> "mittel"
$info_msg = "INFOS:" & @CRLF & "Stufe: Mittel" & @CRLF & "Verloren nach - 7 - Fehltreffern" & @CRLF & "Gewonnen nach - 40 - Treffern" & @CRLF & "Maximaler Abstand zwischen Viereckgeneratrion: 1500 Millisekunden" & @CRLF & "Maximale Wartezeit: 750 Millisekunden"
GUICtrlSetData($lbl_info, $info_msg)
$var = "mittel"
case $cPos[4] = $lbl_schwer And $var <> "schwer"
$info_msg = "INFOS:" & @CRLF & "Stufe: Schwer" & @CRLF & "Verloren nach - 3 - Fehltreffern" & @CRLF & "Gewonnen nach - 60 - Treffern" & @CRLF & "Maximaler Abstand zwischen Viereckgeneratrion: 850 Millisekunden" & @CRLF & "Maximale Wartezeit: 450 Millisekunden" & @CRLF & @CRLF & "ACHTUNG: SCHWER!"
GUICtrlSetData($lbl_info, $info_msg)
$var = "schwer"
case $cPos[4] = $lbl_hart And $var <> "hart"
$info_msg = "INFOS:" & @CRLF & "Stufe: ... Death" & @CRLF & "Verloren nach - 1 - Fehltreffern" & @CRLF & "Gewonnen nach - 70 - Treffern" & @CRLF & "Maximaler Abstand zwischen Viereckgeneratrion: 550 Millisekunden" & @CRLF & "Maximale Wartezeit: 300 Millisekunden" & @CRLF & @CRLF & "VERGISS ES!"
GUICtrlSetData($lbl_info, $info_msg)
$var = "hart"
case $cPos[4] = $lbl_beenden And $var <> "beenden"
GUICtrlSetData($lbl_info, "Willst du schon aufgeben?")
$var = "beenden"
EndSelect
WEnd
GUICtrlDelete($lbl_beenden)
GUICtrlDelete($lbl_leicht)
GUICtrlDelete($lbl_mittel)
GUICtrlDelete($lbl_schwer)
GUICtrlDelete($lbl_hart)
GUICtrlDelete($lbl_info)
if $schwierigkeit = "leicht" Then
$random_speed = 2000
$daneben_speed = 1000
$treffer_gewonnen = 20
$treffer_verloren = 10
$speed = 17
$speed_abstand = 10
EndIf
if $schwierigkeit = "mittel" Then
$random_speed = 1500
$daneben_speed = 750
$treffer_gewonnen = 40
$treffer_verloren = 7
$speed = 5
$speed_abstand = 11
EndIf
if $schwierigkeit = "schwer" Then
$random_speed = 850
$daneben_speed = 450
$treffer_gewonnen = 60
$treffer_verloren = 3
$speed = 1
$speed_abstand = 30
EndIf
if $schwierigkeit = "hart" Then
$random_speed = 550
$daneben_speed = 300
$treffer_gewonnen = 70
$treffer_verloren = 1
$speed = 1
$speed_abstand = 30
EndIf
$fail_lbl = GUICtrlCreateLabel("Daneben: " & $wPressed, 100, 500, 500, 50)
GUICtrlSetFont(-1, 20, 300, 0, "Times New Roman")
GUICtrlSetColor(-1, 0xFF0000)
$good_lbl = GUICtrlCreateLabel( "Getroffen: " & $gPressed, 100, 550, 300, 50)
GUICtrlSetFont(-1, 20, 300, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x00FF00)
Global $GO_lbl = GUICtrlCreateLabel("", 600, 200, 300, 90)
GUICtrlSetColor(-1, 0x1F3FF0)
GUICtrlSetFont(-1, 70, 300, 0, "Arial")
GUICtrlCreateLabel("Hilfe:", 750, 500, 100, 40)
GUICtrlSetFont(-1, 24, 1200, 4, "Courier New")
GUICtrlSetColor(-1, 0xF0F000)
$hilfe_text = "Es erscheinen immer in zufälligen Abständen Gelbe Vierecke an einer der vier Ecken des Kreuzes. Man muss nun die jeweilige Pfeiltaste drücken, die zu dem Viereck zeigt. Wenn das Gelbe viereck nun an der Rechten Ecke des Kreuzes ist, muss man die rechte Pfeiltaste drücken. Wenn man binnen " & $daneben_speed & " Millisekunden Sekunden von erscheinen des Gelben Vierecks keine Pfeiltaste gedrückt hat, hat man verloren. Man gewinnt indem man " & $treffer_gewonnen & " mal die Gelben Vierecke getroffen hat."
GUICtrlCreateLabel($hilfe_text, 750, 550, 300, 200)
GUICtrlSetFont(-1, 10, 550, 0)
GUISetState()
Global $lbl_start = GUICtrlCreateLabel(" Start", 750, 105, 230, 30)
GUICtrlSetFont(-1, 20, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0x000FF00)
Global $lbl_exit = GUICtrlCreateLabel(" Beenden", 750, 145, 230, 30)
GUICtrlSetFont(-1, 20, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0x000FF00)
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$aPoints[0][0] = 12
$aPoints[1][0] = 330
$aPoints[1][1] = 230
$aPoints[2][0] = 330
$aPoints[2][1] = 100
$aPoints[3][0] = 370
$aPoints[3][1] = 100
$aPoints[4][0] = 370
$aPoints[4][1] = 230
$aPoints[5][0] = 500
$aPoints[5][1] = 230
$aPoints[6][0] = 500
$aPoints[6][1] = 270
$aPoints[7][0] = 370
$aPoints[7][1] = 270
$aPoints[8][0] = 370
$aPoints[8][1] = 400
$aPoints[9][0] = 330
$aPoints[9][1] = 400
$aPoints[10][0] = 330
$aPoints[10][1] = 270
$aPoints[11][0] = 200
$aPoints[11][1] = 270
$aPoints[12][0] = 200
$aPoints[12][1] = 230
$hPen = _GDIPlus_BrushCreateSolid(0xFF000000)
sleep(1)
_GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints, $hPen)
while 1
$msg = GUIGetMsg()
Select
case $msg = $lbl_exit
Exit
case $msg = $lbl_start
ExitLoop
EndSelect
WEnd
GUICtrlSetData($GO_lbl, "3")
sleep(500)
GUICtrlSetData($GO_lbl, "2")
sleep(500)
GUICtrlSetData($GO_lbl, "1")
sleep(500)
GUICtrlSetData($GO_lbl, "GO!!")
sleep(500)
GUICtrlSetData($GO_lbl, "")
_choose_random_pos()
Func _choose_random_pos()
$iPos = Random(1,4, 1)
Switch $iPos
case 1
_create_P1()
case 2
_create_P2()
case 3
_create_P3()
case 4
_create_P4()
EndSwitch
EndFunc
func _create_P1()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 330, $iY = 60
_GDIPlus_GraphicsFillRect($hGraphic, 330, 60, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(26) Then
$gPressed += 1
_schiess("Oben")
Else
if _IsPressed(25) Or _IsPressed(27) Or _IsPressed(28) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = $treffer_verloren Then _end_Point()
sleep(200)
$timer_start = TimerInit()
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= $daneben_speed Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = $treffer_verloren
_end_Point()
EndIf
WEnd
EndFunc
func _create_P2()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 500, $iY = 230
_GDIPlus_GraphicsFillRect($hGraphic, 500, 230, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(27) Then
$gPressed += 1
_schiess("Rechts")
_end_Point()
Else
if _IsPressed(26) Or _IsPressed(25) Or _IsPressed(28) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = $treffer_verloren Then _end_Point()
sleep(200)
$timer_start = TimerInit()
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= $daneben_speed Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = $treffer_verloren
_end_Point()
EndIf
WEnd
EndFunc
func _create_P3()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 330, $iY = 400
_GDIPlus_GraphicsFillRect($hGraphic, 330, 400, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(28) Then
$gPressed += 1
_schiess("Unten")
_end_Point()
Else
if _IsPressed(26) Or _IsPressed(27) Or _IsPressed(25) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = $treffer_verloren Then _end_Point()
sleep(200)
$timer_start = TimerInit()
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= $daneben_speed Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = $treffer_verloren
_end_Point()
EndIf
WEnd
EndFunc
func _create_P4()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 140, $iY = 230
_GDIPlus_GraphicsFillRect($hGraphic, 160, 230, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(25) Then
$gPressed += 1
_schiess("Links")
_end_Point()
Else
if _IsPressed(26) Or _IsPressed(27) Or _IsPressed(28) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = $treffer_verloren Then _end_Point()
sleep(200)
$timer_start = TimerInit()
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= $daneben_speed Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = $treffer_verloren
_end_Point()
EndIf
WEnd
EndFunc
func _end_Point()
GUICtrlSetData($good_lbl, "Getroffen: " & $gPressed)
$hPen = _GDIPlus_BrushCreateSolid(0xFF343434)
_GDIPlus_GraphicsFillRect($hGraphic, 330, 40, 40, 60, $hPen); $iX = 330, $iY = 100
_GDIPlus_GraphicsFillRect($hGraphic, 330, 400, 40, 60, $hPen); $iX = 330, $iY = 400
_GDIPlus_GraphicsFillRect($hGraphic, 500, 230, 60, 40, $hPen); $iX = 500, $iY = 230
_GDIPlus_GraphicsFillRect($hGraphic, 140, 230, 60, 40, $hPen); $iX = 160, $iY = 230
if $gPressed = $treffer_gewonnen Then
MsgBox(0, "WIN", "Sie haben gewonnen")
Exit
EndIf
if $wPressed = $treffer_verloren Then
MsgBox(0, "LOOSE", "Sie haben verloren")
Exit
EndIf
$iWait = Random(200, $random_speed, 100)
sleep($iWait)
_choose_random_pos()
EndFunc
func _schiess($Richtung)
$hPen = _GDIPlus_BrushCreateSolid(0xFFFF0000)
$hPen_uebermalen = _GDIPlus_BrushCreateSolid(0xFF000000)
if $Richtung = "Oben" Then
$hX = 345
$hY = 210
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY + $speed_abstand, 10, 40, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 10, 40, $hPen)
if $hY <= 60 Then _end_Point()
$hY -= $speed_abstand
sleep($speed)
WEnd
EndIf
if $Richtung = "Unten" Then ; $iX = 330, $iY = 400
$hX = 345
$hY = 230
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY - $speed_abstand, 10, 40, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 10, 40, $hPen)
if $hY >= 400 Then _end_Point()
$hY += $speed_abstand
sleep($speed)
WEnd
EndIf
if $Richtung = "Rechts" Then ; $iX = 500, $iY = 230
$hX = 350
$hY = 245
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX - $speed_abstand, $hY, 40, 10, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 40, 10, $hPen)
if $hX >= 500 Then _end_Point()
$hX += $speed_abstand
sleep($speed)
WEnd
EndIf
if $Richtung = "Links" Then ; $iX = 160, $iY = 230
$hX = 350
$hY = 245
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX + $speed_abstand, $hY, 40, 10, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 40, 10, $hPen)
if $hX <= 160 Then _end_Point()
$hX -= $speed_abstand
sleep($speed)
WEnd
EndIf
EndFunc
func _exit_noob()
GUICtrlDelete($lbl_beenden)
GUICtrlDelete($lbl_leicht)
GUICtrlDelete($lbl_mittel)
GUICtrlDelete($lbl_schwer)
GUICtrlDelete($lbl_hart)
GUICtrlDelete($lbl_info)
GUICtrlCreateLabel("Wusst ichs doch .....", @DesktopWidth / 2 - 400, @DesktopHeight / 2 - 100, 800, 60)
GUICtrlSetFont(-1, 40, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0xFF0000)
sleep(1300)
Exit
EndFunc
V1.1:
- 3 Schwierigkeitsstufen
- Vormenü
- schneller abschießen
CodeV1.1:
Spoiler anzeigen
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Misc.au3>
Global $aPoints[13][2],$bPoints[13][2], $hWnd, $hGraphic, $wPressed = 0, $gPressed = 0, $iX, $iY, $GO_lbl
_GDIPlus_Startup()
$hWnd = GUICreate("Geschick", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetBkColor(0x343434)
Global $lbl_leicht = GUICtrlCreateLabel(" Leicht", @DesktopWidth / 2 - 200, 200, 400, 60)
GUICtrlSetFont(-1, 30, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0x000FF00)
Global $lbl_mittel = GUICtrlCreateLabel(" Mittel", @DesktopWidth / 2 - 200, 280, 400, 60)
GUICtrlSetFont(-1, 30, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0xFFFF00)
Global $lbl_schwer = GUICtrlCreateLabel(" Schwer", @DesktopWidth / 2 - 200, 360, 400, 60)
GUICtrlSetFont(-1, 30, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0xFF0000)
Global $lbl_beenden = GUICtrlCreateLabel(" Beenden", @DesktopWidth / 2 - 200, 440, 400, 60)
GUICtrlSetFont(-1, 30, 750,0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUISetState()
while 1
$msg = GUIGetMsg()
Select
case $msg = $lbl_leicht
$schwierigkeit = "leicht"
ExitLoop
case $msg = $lbl_mittel
$schwierigkeit = "mittel"
ExitLoop
case $msg = $lbl_schwer
$schwierigkeit = "schwer"
ExitLoop
case $msg = $lbl_beenden
Exit
EndSelect
WEnd
GUICtrlDelete($lbl_beenden)
GUICtrlDelete($lbl_leicht)
GUICtrlDelete($lbl_mittel)
GUICtrlDelete($lbl_schwer)
if $schwierigkeit = "leicht" Then
$random_speed = 2000
$daneben_speed = 1000
$treffer_gewonnen = 20
$treffer_verloren = 10
EndIf
if $schwierigkeit = "mittel" Then
$random_speed = 1500
$daneben_speed = 750
$treffer_gewonnen = 30
$treffer_verloren = 7
EndIf
if $schwierigkeit = "schwer" Then
$random_speed = 1000
$daneben_speed = 500
$treffer_gewonnen = 40
$treffer_verloren = 5
EndIf
$fail_lbl = GUICtrlCreateLabel("Daneben: " & $wPressed, 100, 500, 500, 50)
GUICtrlSetFont(-1, 20, 300, 0, "Times New Roman")
GUICtrlSetColor(-1, 0xFF0000)
$good_lbl = GUICtrlCreateLabel( "Getroffen: " & $gPressed, 100, 550, 300, 50)
GUICtrlSetFont(-1, 20, 300, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x00FF00)
Global $GO_lbl = GUICtrlCreateLabel("", 600, 200, 300, 90)
GUICtrlSetColor(-1, 0x1F3FF0)
GUICtrlSetFont(-1, 70, 300, 0, "Arial")
GUICtrlCreateLabel("Hilfe:", 750, 500, 100, 40)
GUICtrlSetFont(-1, 24, 1200, 4, "Courier New")
GUICtrlSetColor(-1, 0xF0F000)
$hilfe_text = "Es erscheinen immer in zufälligen Abständen Gelbe Vierecke an einer der vier Ecken des Kreuzes. Man muss nun die jeweilige Pfeiltaste drücken, die zu dem Viereck zeigt. Wenn das Gelbe viereck nun an der Rechten Ecke des Kreuzes ist, muss man die rechte Pfeiltaste drücken. Wenn man binnen " & $daneben_speed & " Millisekunden Sekunden von erscheinen des Gelben Vierecks keine Pfeiltaste gedrückt hat, hat man verloren. Man gewinnt indem man " & $treffer_gewonnen & " mal die Gelben Vierecke getroffen hat."
GUICtrlCreateLabel($hilfe_text, 750, 550, 300, 200)
GUICtrlSetFont(-1, 10, 550, 0)
GUISetState()
Global $lbl_start = GUICtrlCreateLabel(" Start", 750, 105, 230, 30)
GUICtrlSetFont(-1, 20, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0x000FF00)
Global $lbl_exit = GUICtrlCreateLabel(" Beenden", 750, 145, 230, 30)
GUICtrlSetFont(-1, 20, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0x000FF00)
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$aPoints[0][0] = 12
$aPoints[1][0] = 330
$aPoints[1][1] = 230
$aPoints[2][0] = 330
$aPoints[2][1] = 100
$aPoints[3][0] = 370
$aPoints[3][1] = 100
$aPoints[4][0] = 370
$aPoints[4][1] = 230
$aPoints[5][0] = 500
$aPoints[5][1] = 230
$aPoints[6][0] = 500
$aPoints[6][1] = 270
$aPoints[7][0] = 370
$aPoints[7][1] = 270
$aPoints[8][0] = 370
$aPoints[8][1] = 400
$aPoints[9][0] = 330
$aPoints[9][1] = 400
$aPoints[10][0] = 330
$aPoints[10][1] = 270
$aPoints[11][0] = 200
$aPoints[11][1] = 270
$aPoints[12][0] = 200
$aPoints[12][1] = 230
$hPen = _GDIPlus_BrushCreateSolid(0xFF000000)
sleep(1)
_GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints, $hPen)
while 1
$msg = GUIGetMsg()
Select
case $msg = $lbl_exit
Exit
case $msg = $lbl_start
ExitLoop
EndSelect
WEnd
GUICtrlSetData($GO_lbl, "3")
sleep(500)
GUICtrlSetData($GO_lbl, "2")
sleep(500)
GUICtrlSetData($GO_lbl, "1")
sleep(500)
GUICtrlSetData($GO_lbl, "GO!!")
sleep(500)
GUICtrlSetData($GO_lbl, "")
_choose_random_pos()
Func _choose_random_pos()
$iPos = Random(1,4, 1)
Switch $iPos
case 1
_create_P1()
case 2
_create_P2()
case 3
_create_P3()
case 4
_create_P4()
EndSwitch
EndFunc
func _create_P1()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 330, $iY = 60
_GDIPlus_GraphicsFillRect($hGraphic, 330, 60, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(26) Then
$gPressed += 1
_schiess("Oben")
Else
if _IsPressed(25) Or _IsPressed(27) Or _IsPressed(28) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = $treffer_verloren Then _end_Point()
sleep(200)
$timer_start = TimerInit()
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= $daneben_speed Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = $treffer_verloren
_end_Point()
EndIf
WEnd
EndFunc
func _create_P2()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 500, $iY = 230
_GDIPlus_GraphicsFillRect($hGraphic, 500, 230, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(27) Then
$gPressed += 1
_schiess("Rechts")
_end_Point()
Else
if _IsPressed(26) Or _IsPressed(25) Or _IsPressed(28) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = $treffer_verloren Then _end_Point()
sleep(200)
$timer_start = TimerInit()
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= $daneben_speed Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = $treffer_verloren
_end_Point()
EndIf
WEnd
EndFunc
func _create_P3()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 330, $iY = 400
_GDIPlus_GraphicsFillRect($hGraphic, 330, 400, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(28) Then
$gPressed += 1
_schiess("Unten")
_end_Point()
Else
if _IsPressed(26) Or _IsPressed(27) Or _IsPressed(25) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = $treffer_verloren Then _end_Point()
sleep(200)
$timer_start = TimerInit()
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= $daneben_speed Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = $treffer_verloren
_end_Point()
EndIf
WEnd
EndFunc
func _create_P4()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 160, $iY = 230
_GDIPlus_GraphicsFillRect($hGraphic, 160, 230, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(25) Then
$gPressed += 1
_schiess("Links")
_end_Point()
Else
if _IsPressed(26) Or _IsPressed(27) Or _IsPressed(28) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = $treffer_verloren Then _end_Point()
sleep(200)
$timer_start = TimerInit()
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= $daneben_speed Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = $treffer_verloren
_end_Point()
EndIf
WEnd
EndFunc
func _end_Point()
GUICtrlSetData($good_lbl, "Getroffen: " & $gPressed)
$hPen = _GDIPlus_BrushCreateSolid(0xFF343434)
_GDIPlus_GraphicsFillRect($hGraphic, $iX, $iY, 40, 60, $hPen)
if $gPressed = $treffer_gewonnen Then
MsgBox(0, "WIN", "Sie haben gewonnen")
Exit
EndIf
if $wPressed = $treffer_verloren Then
MsgBox(0, "LOOSE", "Sie haben verloren")
Exit
EndIf
$iWait = Random(200, $random_speed, 100)
sleep($iWait)
_choose_random_pos()
EndFunc
func _schiess($Richtung)
$hPen = _GDIPlus_BrushCreateSolid(0xFFFF0000)
$hPen_uebermalen = _GDIPlus_BrushCreateSolid(0xFF000000)
$speed = 1
if $Richtung = "Oben" Then
$hX = 345
$hY = 210
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY + 30, 10, 40, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 10, 40, $hPen)
if $hY <= 60 Then _end_Point()
$hY -= 30
sleep($speed)
WEnd
EndIf
if $Richtung = "Unten" Then ; $iX = 330, $iY = 400
$hX = 345
$hY = 230
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY - 30, 10, 40, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 10, 40, $hPen)
if $hY >= 400 Then _end_Point()
$hY += 30
sleep($speed)
WEnd
EndIf
if $Richtung = "Rechts" Then ; $iX = 500, $iY = 230
$hX = 350
$hY = 245
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX - 30, $hY, 40, 10, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 40, 10, $hPen)
if $hX >= 500 Then _end_Point()
$hX += 30
sleep($speed)
WEnd
EndIf
if $Richtung = "Links" Then ; $iX = 160, $iY = 230
$hX = 350
$hY = 245
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX + 30, $hY, 40, 10, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 40, 10, $hPen)
if $hX <= 160 Then _end_Point()
$hX -= 30
sleep($speed)
WEnd
EndIf
EndFunc
Code V1.0:
Spoiler anzeigen
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Misc.au3>
Global $aPoints[13][2],$bPoints[13][2], $hWnd, $hGraphic, $wPressed = 0, $gPressed = 0, $iX, $iY, $GO_lbl
_GDIPlus_Startup()
$hWnd = GUICreate("Geschick", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetBkColor(0x343434)
$fail_lbl = GUICtrlCreateLabel("Daneben: " & $wPressed, 100, 500, 500, 50)
GUICtrlSetFont(-1, 20, 300, 0, "Times New Roman")
GUICtrlSetColor(-1, 0xFF0000)
$good_lbl = GUICtrlCreateLabel( "Getroffen: " & $gPressed, 100, 550, 300, 50)
GUICtrlSetFont(-1, 20, 300, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x00FF00)
Global $GO_lbl = GUICtrlCreateLabel("", 600, 200, 300, 90)
GUICtrlSetColor(-1, 0x1F3FF0)
GUICtrlSetFont(-1, 70, 300, 0, "Arial")
GUICtrlCreateLabel("Hilfe:", 750, 500, 100, 40)
GUICtrlSetFont(-1, 24, 1200, 4, "Courier New")
GUICtrlSetColor(-1, 0xF0F000)
$hilfe_text = "Es erscheinen immer in zufälligen Abständen Gelbe Vierecke an einer der vier Ecken des Kreuzes. Man muss nun die jeweilige Pfeiltaste drücken, die zu dem Viereck zeigt. Wenn das Gelbe viereck nun an der Rechten Ecke des Kreuzes ist, muss man die rechte Pfeiltaste drücken. Wenn man binnen 500 Millisekunden Sekunden von erscheinen des Gelben Vierecks keine Pfeiltaste gedrückt hat, hat man verloren."
GUICtrlCreateLabel($hilfe_text, 750, 550, 300, 200)
GUICtrlSetFont(-1, 10, 550, 0)
GUISetState()
Global $lbl_start = GUICtrlCreateLabel(" Start", 750, 105, 230, 30)
GUICtrlSetFont(-1, 20, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0x000FF00)
Global $lbl_exit = GUICtrlCreateLabel(" Beenden", 750, 145, 230, 30)
GUICtrlSetFont(-1, 20, 750,0, "Courier New")
GUICtrlSetBkColor(-1, 0x000FF00)
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$aPoints[0][0] = 12
$aPoints[1][0] = 330
$aPoints[1][1] = 230
$aPoints[2][0] = 330
$aPoints[2][1] = 100
$aPoints[3][0] = 370
$aPoints[3][1] = 100
$aPoints[4][0] = 370
$aPoints[4][1] = 230
$aPoints[5][0] = 500
$aPoints[5][1] = 230
$aPoints[6][0] = 500
$aPoints[6][1] = 270
$aPoints[7][0] = 370
$aPoints[7][1] = 270
$aPoints[8][0] = 370
$aPoints[8][1] = 400
$aPoints[9][0] = 330
$aPoints[9][1] = 400
$aPoints[10][0] = 330
$aPoints[10][1] = 270
$aPoints[11][0] = 200
$aPoints[11][1] = 270
$aPoints[12][0] = 200
$aPoints[12][1] = 230
$hPen = _GDIPlus_BrushCreateSolid(0xFF000000)
sleep(1)
_GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints, $hPen)
while 1
$msg = GUIGetMsg()
Select
case $msg = $lbl_exit
Exit
case $msg = $lbl_start
ExitLoop
EndSelect
WEnd
GUICtrlSetData($GO_lbl, "3")
sleep(500)
GUICtrlSetData($GO_lbl, "2")
sleep(500)
GUICtrlSetData($GO_lbl, "1")
sleep(500)
GUICtrlSetData($GO_lbl, "GO!!")
sleep(500)
GUICtrlSetData($GO_lbl, "")
_choose_random_pos()
Func _choose_random_pos()
$iPos = Random(1,4, 1)
Switch $iPos
case 1
_create_P1()
case 2
_create_P2()
case 3
_create_P3()
case 4
_create_P4()
EndSwitch
EndFunc
func _create_P1()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 330, $iY = 60
_GDIPlus_GraphicsFillRect($hGraphic, 330, 60, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(26) Then
$gPressed += 1
_schiess("Oben")
Else
if _IsPressed(25) Or _IsPressed(27) Or _IsPressed(28) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = 10 Then _end_Point()
sleep(200)
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= 500 Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = 10
_end_Point()
EndIf
WEnd
EndFunc
func _create_P2()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 500, $iY = 230
_GDIPlus_GraphicsFillRect($hGraphic, 500, 230, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(27) Then
$gPressed += 1
_schiess("Rechts")
_end_Point()
Else
if _IsPressed(26) Or _IsPressed(25) Or _IsPressed(28) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = 10 Then _end_Point()
sleep(200)
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= 500 Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = 10
_end_Point()
EndIf
WEnd
EndFunc
func _create_P3()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 330, $iY = 400
_GDIPlus_GraphicsFillRect($hGraphic, 330, 400, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(28) Then
$gPressed += 1
_schiess("Unten")
_end_Point()
Else
if _IsPressed(26) Or _IsPressed(27) Or _IsPressed(25) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = 10 Then _end_Point()
sleep(200)
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= 500 Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = 10
_end_Point()
EndIf
WEnd
EndFunc
func _create_P4()
Global $hPen = _GDIPlus_BrushCreateSolid(0xFFFFFF00), $iX = 160, $iY = 230
_GDIPlus_GraphicsFillRect($hGraphic, 160, 230, 40, 40, $hPen)
$timer_start = TimerInit()
While 1
if _IsPressed(25) Then
$gPressed += 1
_schiess("Links")
_end_Point()
Else
if _IsPressed(26) Or _IsPressed(27) Or _IsPressed(28) Then
$wPressed += 1
GUICtrlSetData($fail_lbl, "Daneben: " & $wPressed)
if $wPressed = 10 Then _end_Point()
sleep(200)
EndIf
EndIf
if GUIGetMsg() = $lbl_exit Then Exit
if TimerDiff($timer_start) >= 500 Then
GUICtrlSetData($fail_lbl, "Daneben: --- Zu lange gewartet ---")
$wPressed = 10
_end_Point()
EndIf
WEnd
EndFunc
func _end_Point()
GUICtrlSetData($good_lbl, "Getroffen: " & $gPressed)
$hPen = _GDIPlus_BrushCreateSolid(0xFF343434)
_GDIPlus_GraphicsFillRect($hGraphic, $iX, $iY, 40, 40, $hPen)
if $gPressed = 20 Then
MsgBox(0, "WIN", "Sie haben gewonnen")
Exit
EndIf
if $wPressed = 10 Then
MsgBox(0, "LOOSE", "Sie haben verloren")
Exit
EndIf
$iWait = Random(200, 2000, 100)
sleep($iWait)
_choose_random_pos()
EndFunc
func _schiess($Richtung)
$hPen = _GDIPlus_BrushCreateSolid(0xFFFF0000)
$hPen_uebermalen = _GDIPlus_BrushCreateSolid(0xFF000000)
$speed = 10
if $Richtung = "Oben" Then
$hX = 345
$hY = 210
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY + 10, 10, 40, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 10, 40, $hPen)
if $hY <= 60 Then _end_Point()
$hY -= 10
sleep($speed)
WEnd
EndIf
if $Richtung = "Unten" Then ; $iX = 330, $iY = 400
$hX = 345
$hY = 230
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY - 10, 10, 40, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 10, 40, $hPen)
if $hY >= 400 Then _end_Point()
$hY += 10
sleep($speed)
WEnd
EndIf
if $Richtung = "Rechts" Then ; $iX = 500, $iY = 230
$hX = 350
$hY = 245
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX - 10, $hY, 40, 10, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 40, 10, $hPen)
if $hX >= 500 Then _end_Point()
$hX += 10
sleep($speed)
WEnd
EndIf
if $Richtung = "Links" Then ; $iX = 160, $iY = 230
$hX = 350
$hY = 245
while 1
_GDIPlus_GraphicsFillRect($hGraphic, $hX + 10, $hY, 40, 10, $hPen_uebermalen)
_GDIPlus_GraphicsFillRect($hGraphic, $hX, $hY, 40, 10, $hPen)
if $hX <= 160 Then _end_Point()
$hX -= 10
sleep($speed)
WEnd
EndIf
EndFunc
Für Verbesserungen, etc. bin ich immer offen!
mfg
hauke96