
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiConstants.au3>
#include <GdiPlus.au3>;das include
#include <Misc.au3>
MsgBox (0, "Aufgabe", "Komme zum Ziel ohne die schwarzen Balken zu berühren!!!")

OnAutoItExitRegister("_end") ; die Funktion _end am Ende des Scriptes ausführen

$x = 0;x und y deklarieren
$y = 0

$Gui = GUICreate("Beispiel", 179, 163, 543,294, -1)
GUISetState(@SW_SHOW)

_GDIPlus_Startup() ;Gdi starten

$figur = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\figur.png")
$bk = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\weiss.png")
$balken = _GDIPlus_ImageLoadFromFile (@ScriptDir & "\balken.png")
$ziel = _GDIPlus_ImageLoadFromFile (@ScriptDir & "\ziel.gif")
$height = _GDIPlus_ImageGetHeight($figur)
$width = _GDIPlus_ImageGetWidth($figur)
$verhaelnis = $height / $width
$graphic = _GDIPlus_GraphicsCreateFromHWND($Gui)
$bitmap = _GDIPlus_BitmapCreateFromGraphics(179, 163, $graphic)
$buffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
$buffer1 = _GDIPlus_ImageGetGraphicsContext($bitmap)

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
Select
Case _IsPressed(25) and not $x <= 0  ; nach links
$x -= 3
Case _IsPressed(26) and not $y <= 0; nach oben
$y -= 3
Case _IsPressed(27) and $x <= 160 ; nach rechts
$x += 3
Case _IsPressed(28) and $y <= 135  ; nach unten
$y += 3
EndSelect


 _GDIPlus_GraphicsDrawImageRect($buffer,$bk,0,0,179, 163)
$balken2 =_GDIPlus_GraphicsDrawImageRect($buffer,$balken,25, 30, 100, 10)
_GDIPlus_GraphicsDrawImageRect ($buffer, $ziel, 160, 135, 20,20 )
_GDIPlus_GraphicsDrawImageRect($buffer,$figur,$x,$y,25, 25 * $verhaelnis)
_GDIPlus_GraphicsDrawImage($graphic, $bitmap, 0, 0)
Sleep(30)



	
	If $y <= 36 and $y >= 15 and $x >= 3 And $x <=123 Then
	
		$x =0
		$y= 0
	
	ElseIf $x >= 155 and $x <= 170 and $y <= 140 and $y >= 115 Then
		MsgBox (0, "Win","Lvl 1 geschafft", 10)
		Exit
		
		
		
	EndIf
	
	
	


WEnd

Func _end ();die Exit funktion
_GDIPlus_GraphicsDispose($graphic);Grafik Objekt freigeben
_GDIPlus_GraphicsDispose($buffer)
_GDIPlus_BitmapDispose($bitmap)
_GDIPlus_ImageDispose ($balken)
_GDIPlus_ImageDispose($figur);Bild Objekt 1 freigeben
_GDIPlus_ImageDispose($bk);Bild Objekt 2 freigeben
_GDIPlus_Shutdown();Ressourcen freigeben
EndFunc
