Hey,
Ich programmiere gerade ein MiniRPG um mich in GDI+ zu trainieren. Mein Problem: Der Zauberer soll einen Partikel rumschießen, aber irgendwie klappts nicht ganz.
Spoiler anzeigen
#include <GuiConstants.au3>
#include <GdiPlus.au3>;das include
#include <Misc.au3>
OnAutoItExitRegister("_end") ; die Funktion _end am Ende des Scriptes ausführen
[/autoit] [autoit][/autoit] [autoit]$x = 0;x und y deklarieren
$y = 0
$Gui = GUICreate("Beispiel", 600, 400, 100, 100)
GUISetState(@SW_SHOW)
_GDIPlus_Startup() ;Gdi starten
[/autoit] [autoit][/autoit] [autoit]$figur = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\char\figur.gif")
$bk = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\stuff\bg.jpg")
$particle_red = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\particles\red.gif")
$height = _GDIPlus_ImageGetHeight($figur)
$width = _GDIPlus_ImageGetWidth($figur)
$verhaelnis = $height / $width
$graphic = _GDIPlus_GraphicsCreateFromHWND($Gui)
$bitmap = _GDIPlus_BitmapCreateFromGraphics(600, 400, $graphic)
$buffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
While 1
_GDIPlus_GraphicsDrawImageRect($buffer, $bk, 0, 0, 600, 400)
_GDIPlus_GraphicsDrawImageRect($buffer, $figur, $x, $y, 40, 40 * $verhaelnis)
_GDIPlus_GraphicsDrawImage($graphic, $bitmap, 0, 0)
Sleep(30)
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
Select
Case _IsPressed(25) And Not $x <= 0; ------------- geändert -------------
$x -= 5
Case _IsPressed(26) And Not $y <= 0; ------------- geändert -------------
$y -= 5
Case _IsPressed(27) And $x <= 555; ------------- geändert -------------
$x += 5
Case _IsPressed(28) And $y <= 355 ; ------------- geändert -------------
$y += 5
Case _IsPressed(20)
For $i=$x To $x + 50
_GDIPlus_GraphicsDrawImageRect($buffer, $particle_red, $i, 50, 15, 15)
Next
EndSelect
WEnd
Func _end();die Exit funktion
_GDIPlus_GraphicsDispose($graphic);Grafik Objekt freigeben
_GDIPlus_GraphicsDispose($buffer)
_GDIPlus_BitmapDispose($bitmap)
_GDIPlus_ImageDispose($figur);Bild Objekt 1 freigeben
_GDIPlus_ImageDispose($bk);Bild Objekt 2 freigeben
_GDIPlus_ImageDispose($particle_red)
_GDIPlus_Shutdown();Ressourcen freigeben
EndFunc ;==>_end
Allerdings kommt nichts wenn ich Space drücke. Weiß jemand wie ich das am besten umsetze?