#include <Misc.au3>
#include <Garfik.au3>

Opt('MustDeclareVars', 1)
Global $aFigur[4][3], $aMove[5], $hGarfik, $hTemp, $hFigur, $hMask

$hGarfik = _Garfik_Startup(@DesktopWidth, @DesktopHeight, 10)

$hTemp = _GDIPlus_BitmapCreateFromFile(@ScriptDir & '\Back.png')
_Garfik_SetBackground($hGarfik, $hTemp)
_GDIPlus_BitmapDispose($hTemp)

$hTemp = _GDIPlus_BitmapCreateFromFile(@ScriptDir & '\Fig.png')
$hMask = _Garfik_MaskCreate($hTemp)
For $iY = 0 To 3
	For $iX = 0 To 2
		$aFigur[$iY][$iX] = _Garfik_ObjectCreateFromMask($hGarfik, $hMask, ($iX + 3) * 24, ($iY + 0) * 32, 24, 32)
	Next
Next
_Garfik_MaskDelete($hMask)
_GDIPlus_BitmapDispose($hTemp)

$aMove[0] = 500
$aMove[1] = 500
$aMove[2] = 0
$aMove[3] = 1
$aMove[4] = 2

While GUIGetMsg() <> -3
	_Garfik_Clear($hGarfik)
	If _IsPressed('25') Then
		$aMove[0] -= 7
		$aMove[2] += $aMove[3]
		$aMove[4] = 3
		If $aMove[2] = 0 Or $aMove[2] = 2 Then $aMove[3] *= -1
	ElseIf _IsPressed('26') Then
		$aMove[1] -= 7
		$aMove[2] += $aMove[3]
		$aMove[4] = 0
		If $aMove[2] = 0 Or $aMove[2] = 2 Then $aMove[3] *= -1
	ElseIf _IsPressed('27') Then
		$aMove[0] += 7
		$aMove[2] += $aMove[3]
		$aMove[4] = 1
		If $aMove[2] = 0 Or $aMove[2] = 2 Then $aMove[3] *= -1
	ElseIf _IsPressed('28') Then
		$aMove[1] += 7
		$aMove[2] += $aMove[3]
		$aMove[4] = 2
		If $aMove[2] = 0 Or $aMove[2] = 2 Then $aMove[3] *= -1
	EndIf
	_Garfik_DrawObject($hGarfik, $aFigur[$aMove[4]][$aMove[2]], $aMove[0], $aMove[1])
	_Garfik_Update($hGarfik)
WEnd

For $iY = 0 To 3
	For $iX = 0 To 2
		_Garfik_ObjectDelete($aFigur[$iY][$iX])
	Next
Next

_Garfik_Shutdown($hGarfik)
