Huhu, mein erstes GDI+ Script !!!
Bewegen mit den Pfeiltasten, das orangene 4eck ist wie eine Mauer
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
_GDIPlus_Startup()
Global $ObjectPos1 = 100, $ObjectPos2 = 100, $ObjectPos3 = 50, $ObjectPos4 = 50
HotKeySet("{LEFT}", "_BewegenLinks")
HotKeySet("{RIGHT}", "_BewegenRechts")
HotKeySet("{UP}", "_BewegenOben")
HotKeySet("{DOWN}", "_BewegenUnten")
Global $GUIWidth = 600, $GUIHeight = 400
Global $Pos1 = 0 , $Pos2 = 0
Global $GUI_Back_Color = 0xFF000000 + 0xECE9D8
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("EMs Journy of GDI+", 600, 400, 192, 124)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$Graphic = _GDIPlus_GraphicsCreateFromHWND($Form1)
$Bitmap = _GDIPlus_BitmapCreateFromGraphics($GUIWidth, $GUIHeight, $Graphic)
$Backbuffer = _GDIPlus_ImageGetGraphicsContext($Bitmap);Kreirt 2te Bitmap die dann auf Front Buffer übertragen wird
$Pen = _GDIPlus_PenCreate(0xFFFFA147)
$Brush = _GDIPlus_BrushCreateSolid(0xFFFFA147)
_GDIPlus_GraphicsFillRect($Graphic, 100, 100, 50, 50, $Brush)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_Exit()
Exit
EndSwitch
_ReDraw()
WEnd
Func _BewegenLinks()
_GDIPlus_GraphicsClear($Backbuffer, $GUI_Back_Color) ;Macht alles "Sauber"
If ($Pos1-50) <= 0 Then
$Pos1 = $GUIWidth
EndIf
If $Pos1-50 = 100 and $Pos2 = 100 Then
Else
$Pos1 -= 50
_GDIPlus_GraphicsDrawRect($Backbuffer, $Pos1, $Pos2, 50, 50)
_GDIPlus_GraphicsDrawImageRect($Graphic, $Bitmap, 0, 0, $GUIWidth, $GUIHeight)
EndIf
EndFunc
Func _BewegenRechts()
_GDIPlus_GraphicsClear($Backbuffer, $GUI_Back_Color)
If ($Pos1+50) >= $GUIWidth Then
$Pos1 = -50
EndIf
If $Pos1+50 = 100 and $Pos2 = 100 Then
Else
$Pos1 += 50
_GDIPlus_GraphicsDrawRect($Backbuffer, $Pos1, $Pos2, 50, 50)
_GDIPlus_GraphicsDrawImageRect($Graphic, $Bitmap, 0, 0, $GUIWidth, $GUIHeight)
EndIf
EndFunc
Func _BewegenOben()
_GDIPlus_GraphicsClear($Backbuffer, $GUI_Back_Color)
If ($Pos2-50) <= 0 Then
$Pos2 = $GUIHeight
EndIf
If $Pos2-50 = 100 and $Pos1 = 100 Then
Else
$Pos2 -= 50
_GDIPlus_GraphicsDrawRect($Backbuffer, $Pos1, $Pos2, 50, 50)
_GDIPlus_GraphicsDrawImageRect($Graphic, $Bitmap, 0, 0, $GUIWidth, $GUIHeight)
EndIf
EndFunc
Func _BewegenUnten()
_GDIPlus_GraphicsClear($Backbuffer, $GUI_Back_Color)
If ($Pos2+50) >= $GUIHeight Then
$Pos2 = -50
EndIf
If $Pos2+50 = 100 and $Pos1 = 100 Then
Else
$Pos2 += 50
_GDIPlus_GraphicsDrawRect($Backbuffer, $Pos1, $Pos2, 50, 50)
_GDIPlus_GraphicsDrawImageRect($Graphic, $Bitmap, 0, 0, $GUIWidth, $GUIHeight)
EndIf
EndFunc
Func _Exit()
_GDIPlus_Shutdown()
_GDIPlus_ShutDown()
_GDIPlus_GraphicsDispose($Graphic)
_GDIPlus_BitmapDispose($Bitmap)
_GDIPlus_PenDispose($Pen)
_GDIPlus_BrushDispose($Brush)
EndFunc
Func _ReDraw()
_GDIPlus_GraphicsFillRect($Graphic, 100, 100, 50, 50, $Brush)
EndFunc