Wie wäre es dann damit (für eine optionale Tastatursteuerung)^^
Mit den verschiedenen Variablen am Anfang kann man ja auch den Schwierigkeitsgrad verändern.
Spoiler anzeigen
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <Misc.au3>
Opt("MouseCoordMode", 2)
[/autoit] [autoit][/autoit] [autoit]$iGUIWidth = 400
$iGUIHeight = 400
$GUIColorBG = 0xFFFFFFFF
$iX = 200
$iY = 200
$PosNewX = 200
$PosNewY = 200
$iSpeed = 30
$iSpeedMax = 25
$hWnd = GUICreate("Test", $iGUIWidth, $iGUIHeight)
GUISetState()
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphic)
$hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
_GDIPlus_GraphicsClear($hGraphic, $GUIColorBG)
AdlibRegister("_ReDraw", 20)
[/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
AdlibUnRegister()
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()
Exit
EndSwitch
WEnd
Func _ReDraw()
If _IsPressed("25") Then $PosNewX -= $iSpeed
If _IsPressed("27") Then $PosNewX += $iSpeed
$iDiffX = $iX - $PosNewX
If $iDiffX < 0 Then $iDiffX *= -1
$iSpeedX = $iDiffX / 10
If $iSpeedX > $iSpeedMax Then $iSpeedX = $iSpeedMax
If $iX < $PosNewX Then
$iX += $iSpeedX
ElseIf $iX > $PosNewX Then
$iX -= $iSpeedX
EndIf
_GDIPlus_GraphicsClear($hBuffer, $GUIColorBG)
_GDIPlus_GraphicsFillRect($hBuffer, $iX - 25, $iY - 25, 50, 50)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
EndFunc ;==>_ReDraw