Klar, du setzt $Count bei jedem Schleifendurchlauf auf 0 (hier Zeile 22)
Schreib mal
Global $Count = 0
[/autoit]vor die Zeile
[autoit]While 1
[/autoit]und nimm
[autoit]Local $Count = 0
[/autoit]aus der Schleife
Habs hier mal so gemacht:
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.8.0
Author: F4R
Script Function: Krokofight is a Game
Template AutoIt script.
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $Count = 0, $round = 1
[/autoit] [autoit][/autoit] [autoit]#region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Fish! Runde 1", 760, 480, 264, 133)
$Pic1 = GUICtrlCreatePic(@ScriptDir&"\Krokodile.jpg", 1, 0, 28, 28, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
GUISetBkColor(0xFFFFFF)
#endregion ### END Koda GUI section ###
HotKeySet("{up}", "up")
HotKeySet("{down}", "down")
Global $pos = 800
Local $e = 0
Func up()
$e = $e - 10
GUICtrlSetPos($Pic1, 1, $e)
If $e = 450 Then
$e = $e - 10
EndIf
If $e = 0 Then
$e = $e + 10
EndIf
EndFunc ;==>up
Local $e = 0
Func down()
$e = $e + 10
GUICtrlSetPos($Pic1, 1, $e)
If $e = 450 Then
$e = $e - 10
EndIf
If $e = 10 Then
$e = $e + 10
EndIf
EndFunc ;==>down
Local $sleep = 100
While 1
_3(GUIGetMsg())
$random = Random(0, 45, 1)
$p = GUICtrlCreatePic(@ScriptDir&"\feind.jpg", 800, $random*10, 28, 28, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
Do
_3(GUIGetMsg())
$pos = $pos - 10
GUICtrlSetPos($p, $pos)
If _Kollision() Then ExitLoop
Sleep($sleep)
Until $pos = 0
$round += 1
WinSetTitle($Form2, "", "Fish! Runde "&$round&" Treffer "&$Count)
GUICtrlDelete($p)
If $pos = $e Then Exit
[/autoit] [autoit][/autoit] [autoit]$pos = 800
[/autoit] [autoit][/autoit] [autoit]If $sleep > 10 Then
$sleep = $sleep - 10
EndIf
WEnd
Func _Kollision()
$Pos1 = ControlGetPos($Form2, "", $Pic1) ; Position Spieler
$Pos2 = ControlGetPos($Form2, "", $p) ; Position Gegner
If $Pos1[0] >= $Pos2[0] Then
If ($Pos1[1]+$Pos1[3] > $Pos2[1]) And ($Pos1[1] < $Pos2[1]+$Pos2[3]) Then
$Count += 1
Return True
EndIf
EndIf
Return False
EndFunc
Func _3($msg)
If $msg = -3 Then Exit
EndFunc