So bekomme ich keine Fehlermeldung!
Spoiler anzeigen
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Misc.au3>
#include <Array.au3>
HotKeySet("{ESC}", "ende")
HotKeySet("{Up}", "up")
HotKeySet("{Down}", "down")
HotKeySet("{Left}", "left")
HotKeySet("{Right}", "right")
HotKeySet("{Space}", "shoot")
HotKeySet("w", "b1up")
HotKeySet("s", "b1down")
HotKeySet("a", "b1left")
HotKeySet("d", "b1right")
HotKeySet("q", "b1shoot")
start()
[/autoit] [autoit][/autoit] [autoit]Func start()
Global $dam = "Bilder\main1rechts.jpg"
Global $bam = "Bilder\bot1links.jpg"
Global $pam = "Bilder\panzervorne.jpg"
Global $m = 1
Global $b = 1
Global $xmain = 100
Global $ymain = 100
Global $xb1 = 100
Global $yb1 = 100
Global $ak = 0
Global $gui1 = GUICreate("Autoitshooter", 810, 600, 100, 75)
Global $hintergrund = GUICtrlCreateLabel("", 16, 50, 777, 417)
GUICtrlSetBkColor($hintergrund, 0x0)
Global $main1 = GUICtrlCreatePic($dam, 100, 200, 40, 40)
Global $bot1 = GUICtrlCreatePic($bam, 500, 200, 40, 40)
Global $panzer = GUICtrlCreatePic($pam, 520, 300, 110, 110)
Global $leben = GUICtrlCreateProgress(16, 496, 393, 25)
Global $mana = GUICtrlCreateProgress(16, 536, 393, 25)
Global $waffe1 = GUICtrlCreateButton("Waffe1", 424, 496, 73, 67, 0)
Global $waffe2 = GUICtrlCreateButton("Waffe2", 504, 496, 73, 67, 0)
Global $waffe3 = GUICtrlCreateButton("Waffe3", 584, 496, 73, 67, 0)
Global $spezial = GUICtrlCreateButton("Spezial", 664, 496, 129, 67, 0)
Global $datei = GUICtrlCreateMenu("&Datei")
Global $start = GUICtrlCreateMenuItem("Start", $datei)
Global $pause = GUICtrlCreateMenuItem("Pause", $datei)
Global $ende = GUICtrlCreateMenuItem("Ende", $datei)
Global $optionen = GUICtrlCreateMenu("&Optionen")
Global $hotkeys = GUICtrlCreateMenu("&Hotkeys")
Global $about = GUICtrlCreateMenu("&About")
Global $copyright = GUICtrlCreateMenuItem("Copyright", $about)
Global $mainpos = ControlGetPos("Autoitshooter", "", $main1)
Global $bot1pos = ControlGetPos("Autoitshooter", "", $bot1)
Global $panzerpos = ControlGetPos("Autoitshooter", "", $panzer)
Global $xmain = $mainpos[0]
Global $ymain = $mainpos[1]
Global $xb1 = $bot1pos[0]
Global $yb1 = $bot1pos[1]
GUISetState(@SW_SHOW)
GUICtrlSetData($leben, 100)
GUICtrlSetData($mana, 100)
EndFunc ;==>start
While 1
$msg = GUIGetMsg()
Select
Case $msg = $start
GUIDelete($gui1)
start()
Case $msg = $pause And $ak = 0
$ak = 1
GUICtrlSetData($pause, "Weiter")
Case $msg = $pause And $ak = 1
$ak = 0
GUICtrlSetData($pause, "Pause")
Case $msg = $copyright
MsgBox(64, "Copyright", "(C)2009, Retrokid")
Case $msg = $ende
Exit
Case $msg = $spezial
$bam = "Bilder\bot1blut.jpg"
GUICtrlDelete($bot1)
$bot1 = GUICtrlCreatePic($bam, $xb1, $yb1, 40, 40)
GUICtrlSetState($bot1, $Gui_Disable)
GUICtrlSetData($mana, 0)
GUICtrlSetState($spezial, $Gui_Disable)
$man = 0
For $ma = 1 To 100 Step 1
Sleep(500)
$man += 1
GUICtrlSetData($mana, $man)
If $mainpos[1] = $bot1pos[1] And $mainpos[0] < $bot1pos[0] And ($bot1pos[0] - $mainpos[0]) < 270 Then
$bam = ""
b1left()
Sleep(600)
b1shoot()
Sleep(700)
ElseIf $mainpos[1] = $bot1pos[1] And $mainpos[0] > $bot1pos[0] And ($mainpos[0] - $bot1pos[0]) < 270 Then
$bam = ""
b1right()
Sleep(600)
b1shoot()
Sleep(700)
ElseIf $mainpos[0] = $bot1pos[0] And $mainpos[1] < $bot1pos[1] And ($bot1pos[1] - $mainpos[1]) < 270 Then
$bam = ""
b1up()
Sleep(600)
b1shoot()
Sleep(700)
ElseIf $mainpos[0] = $bot1pos[0] And $mainpos[1] > $bot1pos[1] And ($mainpos[1] - $bot1pos[1]) < 270 Then
$bam = ""
b1down()
Sleep(600)
b1shoot()
Sleep(700)
EndIf
If $mainpos[1] = $bot1pos[1] And $mainpos[0] < $bot1pos[0] Then
b1left()
Sleep(700)
ElseIf $mainpos[1] = $bot1pos[1] And $mainpos[0] > $bot1pos[0] Then
b1right()
Sleep(700)
ElseIf $mainpos[0] = $bot1pos[0] And $mainpos[1] < $bot1pos[1] Then
b1up()
Sleep(700)
ElseIf $mainpos[0] = $bot1pos[0] And $mainpos[1] > $bot1pos[1] Then
b1down()
Sleep(700)
EndIf
Next
GUICtrlSetState($spezial, $Gui_Enable)
Case $msg = $GUI_EVENT_CLOSE
Exit
EndSelect
If $mainpos[1] = $bot1pos[1] And $mainpos[0] < $bot1pos[0] And ($bot1pos[0] - $mainpos[0]) < 270 Then
$bam = ""
b1left()
Sleep(600)
b1shoot()
Sleep(700)
ElseIf $mainpos[1] = $bot1pos[1] And $mainpos[0] > $bot1pos[0] And ($mainpos[0] - $bot1pos[0]) < 270 Then
$bam = ""
b1right()
Sleep(600)
b1shoot()
Sleep(700)
ElseIf $mainpos[0] = $bot1pos[0] And $mainpos[1] < $bot1pos[1] And ($bot1pos[1] - $mainpos[1]) < 270 Then
$bam = ""
b1up()
Sleep(600)
b1shoot()
Sleep(700)
ElseIf $mainpos[0] = $bot1pos[0] And $mainpos[1] > $bot1pos[1] And ($mainpos[1] - $bot1pos[1]) < 270 Then
$bam = ""
b1down()
Sleep(600)
b1shoot()
Sleep(700)
EndIf
If $mainpos[1] = $bot1pos[1] And $mainpos[0] < $bot1pos[0] Then
b1left()
Sleep(700)
ElseIf $mainpos[1] = $bot1pos[1] And $mainpos[0] > $bot1pos[0] Then
b1right()
Sleep(700)
ElseIf $mainpos[0] = $bot1pos[0] And $mainpos[1] < $bot1pos[1] Then
b1up()
Sleep(700)
ElseIf $mainpos[0] = $bot1pos[0] And $mainpos[1] > $bot1pos[1] Then
b1down()
Sleep(700)
EndIf
If $panzerpos[0] - $mainpos[0] < 200 Then
GUICtrlDelete($main1)
ElseIf $mainpos[0] - $panzerpos[0] < 200 Then
GUICtrlDelete($main1)
ElseIf $panzerpos[1] - $mainpos[1] < 200 Then
GUICtrlDelete($main1)
ElseIf $mainpos[1] - $panzerpos[1] < 200 Then
GUICtrlDelete($main1)
EndIf
WEnd
Func ende()
Exit
EndFunc ;==>ende
Func up()
If $dam = "Bilder\main1vorne.jpg" Then
$ymain -= 20
$m = 1
GUICtrlSetPos($main1, $xmain, $ymain)
ElseIf $ak = 1 Then
Sleep(1)
$dam = ""
Else
GUICtrlDelete($main1)
$m = 1
$dam = "Bilder\main1vorne.jpg"
$main1 = GUICtrlCreatePic($dam, $xmain, $ymain, 40, 40)
GUICtrlSetState($main1, $Gui_Disable)
EndIf
EndFunc ;==>up
Func down()
If $dam = "Bilder\main1unten.jpg" Then
$ymain += 20
$m = 2
GUICtrlSetPos($main1, $xmain, $ymain)
ElseIf $ak = 1 Then
Sleep(1)
$dam = ""
Else
GUICtrlDelete($main1)
$m = 2
$dam = "Bilder\main1unten.jpg"
$main1 = GUICtrlCreatePic($dam, $xmain, $ymain, 40, 40)
GUICtrlSetState($main1, $Gui_Disable)
EndIf
EndFunc ;==>down
Func left()
If $dam = "Bilder\main1links.jpg" Then
$xmain -= 20
$m = 3
GUICtrlSetPos($main1, $xmain, $ymain)
ElseIf $ak = 1 Then
Sleep(1)
$dam = ""
Else
GUICtrlDelete($main1)
$m = 3
$dam = "Bilder\main1links.jpg"
$main1 = GUICtrlCreatePic($dam, $xmain, $ymain, 40, 40)
GUICtrlSetState($main1, $Gui_Disable)
EndIf
EndFunc ;==>left
Func right()
If $dam = "Bilder\main1rechts.jpg" Then
$xmain += 20
$m = 4
GUICtrlSetPos($main1, $xmain, $ymain)
ElseIf $ak = 1 Then
Sleep(1)
$dam = ""
Else
GUICtrlDelete($main1)
$m = 4
$dam = "Bilder\main1rechts.jpg"
$main1 = GUICtrlCreatePic($dam, $xmain, $ymain, 40, 40)
GUICtrlSetState($main1, $Gui_Disable)
EndIf
EndFunc ;==>right
Func shoot()
If $ak = 1 Then
Sleep(1)
$m = 0
EndIf
If $m = 1 Then
$muni = GUICtrlCreateLabel("", $xmain, $ymain, 2, 2)
GUICtrlSetPos($muni, $xmain + 29, $ymain - 20)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 29, $ymain - 60)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 29, $ymain - 100)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 29, $ymain - 140)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 29, $ymain - 180)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 29, $ymain - 220)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 29, $ymain - 260)
Sleep(150)
GUICtrlDelete($muni)
ElseIf $m = 2 Then
$muni = GUICtrlCreateLabel("", $xmain, $ymain, 2, 2)
GUICtrlSetPos($muni, $xmain + 10, $ymain + 50)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 10, $ymain + 90)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 10, $ymain + 130)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 10, $ymain + 170)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 10, $ymain + 210)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 10, $ymain + 250)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 10, $ymain + 290)
Sleep(150)
GUICtrlDelete($muni)
ElseIf $m = 3 Then
$muni = GUICtrlCreateLabel("", $xmain, $ymain, 2, 2)
GUICtrlSetPos($muni, $xmain - 10, $ymain + 10)
Sleep(150)
GUICtrlSetPos($muni, $xmain - 50, $ymain + 10)
Sleep(150)
GUICtrlSetPos($muni, $xmain - 90, $ymain + 10)
Sleep(150)
GUICtrlSetPos($muni, $xmain - 130, $ymain + 10)
Sleep(150)
GUICtrlSetPos($muni, $xmain - 170, $ymain + 10)
Sleep(150)
GUICtrlSetPos($muni, $xmain - 210, $ymain + 10)
Sleep(150)
GUICtrlSetPos($muni, $xmain - 250, $ymain + 10)
Sleep(150)
GUICtrlDelete($muni)
ElseIf $m = 4 Then
$muni = GUICtrlCreateLabel("", $xmain, $ymain, 2, 2)
GUICtrlSetPos($muni, $xmain + 50, $ymain + 29)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 90, $ymain + 29)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 130, $ymain + 29)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 170, $ymain + 29)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 210, $ymain + 29)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 250, $ymain + 29)
Sleep(150)
GUICtrlSetPos($muni, $xmain + 290, $ymain + 29)
Sleep(150)
GUICtrlDelete($muni)
EndIf
EndFunc ;==>shoot
Func b1up()
If $bam = "Bilder\bot1vorne.jpg" Then
$yb1 -= 20
$b = 1
GUICtrlSetPos($bot1, $xb1, $yb1)
ElseIf $ak = 1 Then
Sleep(1)
$bam = ""
Else
GUICtrlDelete($bot1)
$b = 1
$bam = "Bilder\bot1vorne.jpg"
$bot1 = GUICtrlCreatePic($bam, $xb1, $yb1, 40, 40)
GUICtrlSetState($bot1, $Gui_Disable)
EndIf
EndFunc ;==>b1up
Func b1down()
If $bam = "Bilder\bot1unten.jpg" Then
$yb1 += 20
$b = 2
GUICtrlSetPos($bot1, $xb1, $yb1)
ElseIf $ak = 1 Then
Sleep(1)
$bam = ""
Else
GUICtrlDelete($bot1)
$b = 2
$bam = "Bilder\bot1unten.jpg"
$bot1 = GUICtrlCreatePic($bam, $xb1, $yb1, 40, 40)
GUICtrlSetState($bot1, $Gui_Disable)
EndIf
EndFunc ;==>b1down
Func b1left()
If $bam = "Bilder\bot1links.jpg" Then
$xb1 -= 20
$b = 3
GUICtrlSetPos($bot1, $xb1, $yb1)
ElseIf $ak = 1 Then
Sleep(1)
$bam = ""
Else
GUICtrlDelete($bot1)
$b = 3
$bam = "Bilder\bot1links.jpg"
$bot1 = GUICtrlCreatePic($bam, $xb1, $yb1, 40, 40)
GUICtrlSetState($bot1, $Gui_Disable)
EndIf
EndFunc ;==>b1left
Func b1right()
If $bam = "Bilder\bot1rechts.jpg" Then
$xb1 += 20
$b = 4
GUICtrlSetPos($bot1, $xb1, $yb1)
ElseIf $ak = 1 Then
Sleep(1)
$bam = ""
Else
GUICtrlDelete($bot1)
$b = 4
$bam = "Bilder\bot1rechts.jpg"
$bot1 = GUICtrlCreatePic($bam, $xb1, $yb1, 40, 40)
GUICtrlSetState($bot1, $Gui_Disable)
EndIf
EndFunc ;==>b1right
Func b1shoot()
If $ak = 1 Then
Sleep(1)
$b = 0
EndIf
If $b = 1 Then
$munib1 = GUICtrlCreateLabel("", $xb1, $yb1, 2, 2)
GUICtrlSetPos($munib1, $xb1 + 29, $yb1 - 20)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 29, $yb1 - 60)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 29, $yb1 - 100)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 29, $yb1 - 140)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 29, $yb1 - 180)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 29, $yb1 - 220)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 29, $yb1 - 260)
Sleep(150)
GUICtrlDelete($munib1)
ElseIf $b = 2 Then
$munib1 = GUICtrlCreateLabel("", $xb1, $yb1, 2, 2)
GUICtrlSetPos($munib1, $xb1 + 10, $yb1 + 50)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 10, $yb1 + 90)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 10, $yb1 + 130)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 10, $yb1 + 170)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 10, $yb1 + 210)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 10, $yb1 + 250)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 10, $yb1 + 290)
Sleep(150)
GUICtrlDelete($munib1)
ElseIf $b = 3 Then
$munib1 = GUICtrlCreateLabel("", $xb1, $yb1, 2, 2)
GUICtrlSetPos($munib1, $xb1 - 10, $yb1 + 10)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 - 50, $yb1 + 10)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 - 90, $yb1 + 10)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 - 130, $yb1 + 10)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 - 170, $yb1 + 10)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 - 210, $yb1 + 10)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 - 250, $yb1 + 10)
Sleep(150)
GUICtrlDelete($munib1)
ElseIf $b = 4 Then
$munib1 = GUICtrlCreateLabel("", $xb1, $yb1, 2, 2)
GUICtrlSetPos($munib1, $xb1 + 50, $yb1 + 29)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 90, $yb1 + 29)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 130, $yb1 + 29)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 170, $yb1 + 29)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 210, $yb1 + 29)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 250, $yb1 + 29)
Sleep(150)
GUICtrlSetPos($munib1, $xb1 + 290, $yb1 + 29)
Sleep(150)
GUICtrlDelete($munib1)
EndIf
EndFunc ;==>b1shoot
;noch unwichtig-------------------------
Func _RectCollision($Rect1X1, $Rect1Y1, $Rect1X2, $Rect1Y2, $Rect2X1, $Rect2Y1, $Rect2X2, $Rect2Y2)
; Prog@ndy
Local Const $tagRECT = "long;long;long;long"
Local $1 = DllStructCreate($tagRECT)
Local $2 = DllStructCreate($tagRECT)
Local $3 = DllStructCreate($tagRECT)
DllStructSetData($1, 1, $Rect1X1)
DllStructSetData($1, 2, $Rect1Y1)
DllStructSetData($1, 3, $Rect1X2)
DllStructSetData($1, 4, $Rect1Y2)
DllStructSetData($2, 1, $Rect2X1)
DllStructSetData($2, 2, $Rect2Y1)
DllStructSetData($2, 3, $Rect2X2)
DllStructSetData($2, 4, $Rect2Y2)
Local $r = DllCall("User32.dll", "int", "IntersectRect", "ptr", DllStructGetPtr($3), "ptr", DllStructGetPtr($1), "ptr", DllStructGetPtr($2))
If @error Then Return SetError(1, 0, 0)
Return $r[0] <> 0
EndFunc ;==>_RectCollision
Gruß,
UEZ