#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=..\Doodle.ico
#AutoIt3Wrapper_Res_Fileversion=7.0.1.2
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#Obfuscator_Parameters=/striponly
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; #INCLUDES# ====================================================================================================================
#include <GDIPlus.au3>
#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <timers.au3>
#include <sound.au3>
#include <inet.au3>
#include <array.au3>
#include <string.au3>
#include <math.au3>
#include <Crypt.au3>
; ===============================================================================================================================


; #OPTIONS# =====================================================================================================================
Opt("GuiOnEventMode", 1)
Opt("MouseCoordMode", 0)
OnAutoItExitRegister("CleanOnExit")
_Crypt_Startup()
; ===============================================================================================================================

; #VARIABLES# ===================================================================================================================
Global Const $Width = 300
Global Const $Height = 460

Global Const $JumpSpeed = 0.15
Global Const $JumpHeight = 80 ;Pixel
Global $MoveSpeed = 0
Global Const $Zeitschrit = 0.2

Global Const $gsImagePath = @ScriptDir & "\Bilder\"
Global $GDIP_STATUS = 0
Global $Federz_Height, $Federo_Height, $Doodle_Height, $rotermob, $Protect, $Protect_Width, $Protect_Height, $Plat_Width, $Flug21, $Flug22, $Doodle_sf_gesch_Height, $Doodle_sf_Height
Global $Rakete, $Newhighscore, $Monster_Gruen, $Monster_Lila, $setufo, $Yeti, $Flug2, $Flug3, $MoveMobr, $MoveMobl, _
		$Gameover, $Scorebackground, $Hut, $Pausebild, $Optionscreen, $Federzu, $Federoffen, $ufo, $sf_schuhe, _
		$Trampolin, $Trampolin1, $pause_up, $pause_down, $menu, $play_again, $Pause_eraenzung, $Platform_weis, $Background, $Start, _
		$DoodleHutl, $DoodleHutr, $DoodleHutl1, $DoodleHutr1, $Punkteleiste, $Platform_gruen, $Platform_hellblau, $Doodle_Rechts, _
		$Doodle_Links, $DoodleRakl, $DoodleRakr, $Doodle_sf_r, $Doodle_sf_l, $Doodle_sf_gesch_l, $Doodle_sf_gesch_r, _
		$Platform_grau, $Platform_braun1, $Platform_braun2, $Platform_rot, $Platform_gelb, $Explusion, $imgBeenden, $Platform_braun

Global $gfWeAreActive = False
Global Enum $ST_main_menu = 0, $ST_playing, $ST_paused, $ST_game_over, $ST_enter_score, $ST_scores, $ST_options, $ST_pause_menu
Global $iStatus = $ST_main_menu

Global $braunf[17], $bAngle[17], $weisweg[13], $aPoints[5][2], $gro60[13], $mobset, $letzeplatte, $sprungtr, $protected, $protectiontimer, $ptimer, $protection, $setloch, $letdie, $yalt, $dAngle, $loch, $ufoset, $bosmon, $Mobexist, $mBewegX, $mobdead, $coordcheck, $geschossen, $aAktuellerDoodle, $mobwidth, $mobheight, $Doodle_Schuss, $aktuellerMob, $coordold, $Kugel, $coord1, $Flug1, $coord2, $coord3, $Bild, $moveup, _
		$schuss[1][4], $moveright, $mobdiff, $mobtimer, $mobtimeron, $change, $MoveMobl, $MoveMobr, $bei90grad[17], $explodiert[13], $soundplaye[13], $gelbweg[13], _
		$rotweg[13], $wtrans[13], $gtrans[13], $image1, $bewegh[20], $Platform_braun1, $Platform_braun2, $federpos[20], $ReadN[5], $gruen_n[13][4], $optioncoloron = 0xff7CB639, _
		$untereplatte = 1, $optioncoloroff = 0xffABA69F, $hutt = 3, $tnorm, $grav = 9.81, $untersprung = 0, $nAktuellerDoodle, $fSprung = 0, $Angle = 0, $sprung = 0, $sprungkraft = 50, _
		$Sprungf = 0, $Sprungnu = 0
Global $Background, $Start, $DoodleHutl, $DoodleHutr, $DoodleHutl1, $DoodleHutr1, $Punkteleiste, $Platform_gruen, $Platform_hellblau, $AktuellerDoodle, $Doodle_sf_gesch_Height, _
		$zuletztresetet = 12, $Doodle_Rechts, $Doodle_Links, $Doodle_Height, $Doodle_Width, $Plat_Width, $DoodleRakl, $DoodleRakr, $Doodle_sf_l, $Platform_weis, $Platform_rot, $Platform_gelb, _
		$Doodle_sf_r, $Platform_grau, $Doodle_sf_gesch_r, $Doodle_sf_gesch_l, $Doodle_sf_Height
Global $punktelimit = 1000, $abstand = -40, $paused = 0, $die = False, $i = 0, $t = 0, $y = $Height - $Doodle_Height, _
		$onplatform = 0, $t1 = 0, $normpos, $huttimer, $ybodenalt, $hutbild = 0, $x25 = $Width / 2 - 64, $y25 = $Height / 2 - 37.5, $NoobyMod = False
Global $plat = 0, $raketeon = 0, $timerrakon = 0, $raketentimer = 0, $move = 0, $score = 0, $scoreplus = 0, $yboden = $Height, _
		$Platmovespeed = 0, $platten = 0, $huton = 0, $nAngle = 0, $timeron = 0, $dll = DllOpen("user32.dll"), $Sprungnu = 0
Global Const $Pi_Div_180 = 4 * ATan(1) / 180
Global Const $PI = 4 * ATan(1)
Global Const $DOODLE_BORDER = 14

Global $bewegrichtung[17] = [Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), _
		Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), _
		Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1)]

Global $vbewegrichtung[17] = [Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), _
		Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), _
		Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1)]

For $n = 0 To 19
	$bewegh[$n] = 0
Next


$gruen_n[0][0] = 200
$gruen_n[1][0] = 150
Global Const $hScoreKey = _Crypt_DeriveKey("!#43534$%§2t6gb", $CALG_RC4)
; ===============================================================================================================================

; #INI VALUES#========================================================================================================================
Global Const $datapath = @ScriptDir & "\Scores.ini"
$wintermod = Number(IniRead($datapath, "Optionen", "Wintermode", "0"))
$movement = Number(IniRead($datapath, "Optionen", "movement", "0"))
$soundoff = Number(IniRead($datapath, "Optionen", "soundoff", "0"))
$DirectionalShooting = Number(IniRead($datapath, "Optionen", "directionalShooting", "0"))
$ScoreHash = Binary(IniRead($datapath, "Optionen", "ScoreHash", ''))
Global $aScores = IniReadSection($datapath, "Scores")
_DecryptScores($aScores, $ScoreHash)

; ===============================================================================================================================

; #SOUND#========================================================================================================================
Global $sPropeller = _SoundOpen(@ScriptDir & "\Sounds\propeller.wav")
Global $sFall = _SoundOpen(@ScriptDir & "\Sounds\falldown.wav")
Global $sJump = _SoundOpen(@ScriptDir & "\Sounds\Jump.wav")
Global $sRakete = _SoundOpen(@ScriptDir & "\Sounds\Jetpack.wav")
Global $sSprung = _SoundOpen(@ScriptDir & "\Sounds\Feder.wav")
Global $sSf = _SoundOpen(@ScriptDir & "\Sounds\springshoes.wav")
Global $sTrampolin = _SoundOpen(@ScriptDir & "\Sounds\trampoline.wav")
Global $sExpl = _SoundOpen(@ScriptDir & "\Sounds\explodingplatform2.wav")
Global $sBreak = _SoundOpen(@ScriptDir & "\Sounds\lomise.wav")
Global $sJumpOnMon = _SoundOpen(@ScriptDir & "\Sounds\jumponmonster.wav")
; ===============================================================================================================================

; #GUI, Events#==================================================================================================================
$GUI1 = GUICreate("Doodle Jump - Beta", $Width, $Height, -1, -1, BitOR($WS_POPUP, $WS_SYSMENU, $WS_MINIMIZEBOX, $WS_BORDER))
GUISetOnEvent($GUI_EVENT_CLOSE, "ende")
GUIRegisterMsg($WM_ACTIVATEAPP, "MY_WM_ACTIVATEAPP")
GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
Global $PAUSEDUMMY = GUICtrlCreateDummy()
GUICtrlSetOnEvent($PAUSEDUMMY, "_pause")
Global $aHotkeys[3][2] = [["{ESC}", $PAUSEDUMMY],["{PAUSE}", $PAUSEDUMMY], ["^p", $PAUSEDUMMY]]
GUISetAccelerators($aHotkeys)
; ===============================================================================================================================

; #GDI+#=========================================================================================================================
_GDIPlus_Startup()
$Graphic = _GDIPlus_GraphicsCreateFromHWND($GUI1)
$Bitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $Graphic)
$Buffer = _GDIPlus_ImageGetGraphicsContext($Bitmap)
$PauseBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $Graphic)
$PauseBuffer = _GDIPlus_ImageGetGraphicsContext($PauseBitmap)
DllCall($ghGDIPdll, "int", "GdipBitmapSetResolution", "handle", $Bitmap, "float", 96, "float", 96)
DllCall($ghGDIPdll, "int", "GdipBitmapSetResolution", "handle", $PauseBitmap, "float", 96, "float", 96)

;============================= für Optionstext
$hFormat = _GDIPlus_StringFormatCreate()

$hFamily = _GDIPlus_FontFamilyCreate("Comic Sans MS")
$hFont = _GDIPlus_FontCreate($hFamily, 11, 1)
$tLayout1 = _GDIPlus_RectFCreate(44, 134, 0, 0)
$tLayout2 = _GDIPlus_RectFCreate(115, 134, 0, 0)
$tLayout3 = _GDIPlus_RectFCreate(49, 252, 0, 0)
$tLayout4 = _GDIPlus_RectFCreate(120, 252, 0, 0)
$tLayout5 = _GDIPlus_RectFCreate(73, 320, 0, 0)
$tLayout6 = _GDIPlus_RectFCreate(160, 320, 0, 0)
$aInfo1 = _GDIPlus_GraphicsMeasureString($Buffer, "mouse", $hFont, $tLayout1, $hFormat)
$aInfo2 = _GDIPlus_GraphicsMeasureString($Buffer, "arrow keys", $hFont, $tLayout2, $hFormat)
$aInfo3 = _GDIPlus_GraphicsMeasureString($Buffer, "on", $hFont, $tLayout3, $hFormat)
$aInfo4 = _GDIPlus_GraphicsMeasureString($Buffer, "off", $hFont, $tLayout4, $hFormat)
$aInfo5 = _GDIPlus_GraphicsMeasureString($Buffer, "on", $hFont, $tLayout5, $hFormat)
$aInfo6 = _GDIPlus_GraphicsMeasureString($Buffer, "off", $hFont, $tLayout6, $hFormat)


;============================= für Optionstextfarbe
$hBrushOptOn = _GDIPlus_BrushCreateSolid($optioncoloron)
$hBrushOptOff = _GDIPlus_BrushCreateSolid($optioncoloroff)
$hBrushDark = _GDIPlus_BrushCreateSolid(0xBB000000)
$hBrushSchein = _GDIPlus_BrushCreateSolid(0x99e9dbc6)

If $wintermod = 1 Then
	_LoadSkin("winter")
Else
	_LoadSkin('')
EndIf
$AktuellerDoodle = $Doodle_Rechts

; ===============================================================================================================================

If $gruen_n[0][0] < 60 + $Doodle_Width And $gruen_n[0][0] + $Plat_Width > 60 + $Doodle_Width Then
	$x = $Width - 60
Else
	$x = 60
EndIf
GUISetState(@SW_SHOW)



While 1
	Sleep(20)
	If Not $gfWeAreActive Then ContinueLoop
	Switch $iStatus
		Case $ST_playing
			$y25 = $Height / 2 - 37.5
			$y26 = $y25 + 36
			$iStatus = _DrawGame_CheckInput()
		Case $ST_paused
			$iStatus = _DrawPause_CheckInput()
		Case $ST_pause_menu
			$iStatus = _DrawPauseMenu_CheckInput()
		Case $ST_game_over
			$iStatus = _DrawGameOver_CheckInput()
		Case $ST_enter_score
			$iStatus = _DrawEnterScore_CheckInput()
		Case $ST_scores
			$iStatus = _DrawScores_CheckInput()
		Case $ST_main_menu
			$iStatus = _DrawMain_CheckInput()
		Case $ST_options
			$iStatus = _DrawOptions_CheckInput()
	EndSwitch
WEnd

Func _DrawMain_CheckInput()
	$y1 = 400 - $Doodle_Height - Round(Abs(Sin($i)) * $JumpHeight)
	$x1 = 50 + $Plat_Width / 2 - $Doodle_Width / 2
	$i += $JumpSpeed
	If $i > $PI Then $i = 0
;~ 	_WinAPI_RedrawWindow($GUI1, "", "", $RDW_UPDATENOW + $RDW_FRAME)


	_GDIPlus_GraphicsDrawImage($Buffer, $Start, 0, 0)
	_GDIPlus_GraphicsDrawImage($Buffer, $Doodle_Rechts, $x1, $y1)
	_GDIPlus_GraphicsDrawImage($Buffer, $Platform_gruen, 50, 400)
	_GDIPlus_GraphicsDrawImage($Buffer, $imgBeenden, $Width - 20, 4)
;~ 	_GDIPlus_GraphicsDrawImageRect($Graphic, $Bitmap, 0, 0, $Width, $Height)
	_WinAPI_RedrawWindow($GUI1, 0, 0, $RDW_INTERNALPAINT)

	Local $aMouseInfo = GUIGetCursorInfo($GUI1)
	If @error Then
		_MouseDownEvent(0)
		Return $ST_main_menu
	ElseIf _MouseDownEvent($aMouseInfo[2]) Then
;~ 		MsgBox(0,$aMouseInfo[0],$aMouseInfo[1])
		Select
			Case $aMouseInfo[0] > 153 And $aMouseInfo[0] < 266 And $aMouseInfo[1] > 295 And $aMouseInfo[1] < 335
				Return $ST_options
			Case $aMouseInfo[0] > 48 And $aMouseInfo[0] < 151 And $aMouseInfo[1] > 122 And $aMouseInfo[1] < 159
;~ 			MsgBox(0, '', "Spielen")
				_NewGame()
				Return $ST_playing
			Case $aMouseInfo[0] > 77 And $aMouseInfo[0] < 183 And $aMouseInfo[1] > 179 And $aMouseInfo[1] < 217
				Return $ST_scores
			Case $aMouseInfo[0] > 186 And $aMouseInfo[0] < 214 And $aMouseInfo[1] > 423 And $aMouseInfo[1] < 444 And $wintermod
				$wintermod = 0
				_LoadSkin()
				Return $ST_main_menu
			Case $aMouseInfo[0] > 151 And $aMouseInfo[0] < 182 And $aMouseInfo[1] > 423 And $aMouseInfo[1] < 443 And Not $wintermod
				$wintermod = 1
				_LoadSkin('winter')
				Return $ST_main_menu
			Case $aMouseInfo[0] > 280 And $aMouseInfo[0] < 296 And $aMouseInfo[1] > 4 And $aMouseInfo[1] < 20
				ende()
			Case $aMouseInfo[0] > 1 And $aMouseInfo[1] > 431 and $aMouseInfo[0] < 36 and $aMouseInfo[1] < 451 and $NoobyMod = False
				_LoadSkin("nooby")
			Case $aMouseInfo[0] > 1 And $aMouseInfo[1] > 431 and $aMouseInfo[0] < 36 and $aMouseInfo[1] < 451 and $NoobyMod = True
				$NoobyMod = False
				_LoadSkin('')
			Case Else
		EndSelect
	EndIf
	Return $ST_main_menu
EndFunc   ;==>_DrawMain_CheckInput

Func _DrawOptions_CheckInput()
	$y = 400 - $Doodle_Height - Round(Abs(Sin($i)) * $JumpHeight)
	$x1 = 50 + $Plat_Width / 2 - $Doodle_Width / 2
	$i += $JumpSpeed
	If $i > $PI Then $i = 0

	_GDIPlus_GraphicsDrawImage($Buffer, $Optionscreen, 0, 0)

	If $movement Then
		_GDIPlus_GraphicsDrawStringEx($Buffer, "mouse", $hFont, $aInfo1[0], $hFormat, $hBrushOptOff)
		_GDIPlus_GraphicsDrawStringEx($Buffer, "arrow keys", $hFont, $aInfo2[0], $hFormat, $hBrushOptOn)
	Else
		_GDIPlus_GraphicsDrawStringEx($Buffer, "mouse", $hFont, $aInfo1[0], $hFormat, $hBrushOptOn)
		_GDIPlus_GraphicsDrawStringEx($Buffer, "arrow keys", $hFont, $aInfo2[0], $hFormat, $hBrushOptOff)
	EndIf
	If $soundoff Then
		_GDIPlus_GraphicsDrawStringEx($Buffer, "on", $hFont, $aInfo3[0], $hFormat, $hBrushOptOff)
		_GDIPlus_GraphicsDrawStringEx($Buffer, "off", $hFont, $aInfo4[0], $hFormat, $hBrushOptOn)
	Else
		_GDIPlus_GraphicsDrawStringEx($Buffer, "on", $hFont, $aInfo3[0], $hFormat, $hBrushOptOn)
		_GDIPlus_GraphicsDrawStringEx($Buffer, "off", $hFont, $aInfo4[0], $hFormat, $hBrushOptOff)
	EndIf
	If $DirectionalShooting Then
		_GDIPlus_GraphicsDrawStringEx($Buffer, "on", $hFont, $aInfo5[0], $hFormat, $hBrushOptOn)
		_GDIPlus_GraphicsDrawStringEx($Buffer, "off", $hFont, $aInfo6[0], $hFormat, $hBrushOptOff)
	Else
		_GDIPlus_GraphicsDrawStringEx($Buffer, "on", $hFont, $aInfo5[0], $hFormat, $hBrushOptOff)
		_GDIPlus_GraphicsDrawStringEx($Buffer, "off", $hFont, $aInfo6[0], $hFormat, $hBrushOptOn)
	EndIf


	_GDIPlus_GraphicsDrawImage($Buffer, $Doodle_Rechts, $x1, $y)
	_GDIPlus_GraphicsDrawImage($Buffer, $Platform_gruen, 50, 400)
	_GDIPlus_GraphicsDrawImage($Buffer, $imgBeenden, $Width - 20, 4)
;~ 	_GDIPlus_GraphicsDrawImageRect($Graphic, $Bitmap, 0, 0, $Width, $Height)
	_WinAPI_RedrawWindow($GUI1, 0, 0, $RDW_INTERNALPAINT)

	Local $aMouseInfo = GUIGetCursorInfo($GUI1)
	If @error Then
		_MouseDownEvent(0)
		Return $ST_options
	ElseIf _MouseDownEvent($aMouseInfo[2]) Then
		Select
			Case $aMouseInfo[0] > 184 And $aMouseInfo[0] < 293 And $aMouseInfo[1] > 366 And $aMouseInfo[1] < 407
				IniWrite($datapath, "Optionen", "movement", $movement)
				IniWrite($datapath, "Optionen", "soundoff", $soundoff)
				IniWrite($datapath, "Optionen", "directionalShooting", $DirectionalShooting)
				Return $ST_main_menu
			Case $aMouseInfo[0] > 45 And $aMouseInfo[0] < 90 And $aMouseInfo[1] > 142 And $aMouseInfo[1] < 152
				$movement = 0
			Case $aMouseInfo[0] > 116 And $aMouseInfo[0] < 196 And $aMouseInfo[1] > 142 And $aMouseInfo[1] < 152
				$movement = 1
			Case $aMouseInfo[0] > 51 And $aMouseInfo[0] < 69 And $aMouseInfo[1] > 261 And $aMouseInfo[1] < 270
				$soundoff = 0
			Case $aMouseInfo[0] > 123 And $aMouseInfo[0] < 147 And $aMouseInfo[1] > 256 And $aMouseInfo[1] < 270
				$soundoff = 1
			Case $aMouseInfo[0] > 76 And $aMouseInfo[0] < 93 And $aMouseInfo[1] > 329 And $aMouseInfo[1] < 339
				$DirectionalShooting = 1
			Case $aMouseInfo[0] > 163 And $aMouseInfo[0] < 186 And $aMouseInfo[1] > 325 And $aMouseInfo[1] < 339
				$DirectionalShooting = 0
			Case $aMouseInfo[0] > 280 And $aMouseInfo[0] < 296 And $aMouseInfo[1] > 4 And $aMouseInfo[1] < 20
				ende()
		EndSelect

	EndIf
	Return $ST_options
EndFunc   ;==>_DrawOptions_CheckInput

Func _DrawScores_CheckInput()
	$y = 400 - $Doodle_Height - Round(Abs(Sin($i)) * $JumpHeight)
	$x1 = 50 + $Plat_Width / 2 - $Doodle_Width / 2
	$i += $JumpSpeed
	If $i > $PI Then $i = 0

	_GDIPlus_GraphicsDrawImage($Buffer, $Scorebackground, 0, 0)
	For $n = 1 To 5
		If $aScores[$n][0] > 0 Then
			_GDIPlus_GraphicsDrawString($Buffer, $aScores[$n][0], $Width - 90, 188 + ($n - 1) * 23, "Comic Sans MS", 12)
			_GDIPlus_GraphicsDrawString($Buffer, $n & ". " & $aScores[$n][1], $Width - 250, 188 + ($n - 1) * 23, "Comic Sans MS", 12)
		EndIf
	Next
	_GDIPlus_GraphicsDrawImage($Buffer, $Doodle_Rechts, $x1, $y)
	_GDIPlus_GraphicsDrawImage($Buffer, $Platform_gruen, 50, 400)
	_GDIPlus_GraphicsDrawImage($Buffer, $imgBeenden, $Width - 20, 4)
;~ 	_GDIPlus_GraphicsDrawImageRect($Graphic, $Bitmap, 0, 0, $Width, $Height)
	_WinAPI_RedrawWindow($GUI1, 0, 0, $RDW_INTERNALPAINT)
	Local $aMouseInfo = GUIGetCursorInfo($GUI1)
	If @error Then
		_MouseDownEvent(0)
		Return $ST_scores
	ElseIf _MouseDownEvent($aMouseInfo[2]) Then

		If $aMouseInfo[0] > 161 And $aMouseInfo[0] < 267 And $aMouseInfo[1] > 380 And $aMouseInfo[1] < 421 Then
			Return $ST_main_menu
		ElseIf $aMouseInfo[0] > 280 And $aMouseInfo[0] < 296 And $aMouseInfo[1] > 4 And $aMouseInfo[1] < 20 Then
			ende()
		EndIf
	EndIf
	Return $ST_scores
EndFunc   ;==>_DrawScores_CheckInput

Func _DrawPause_CheckInput()

	_GDIPlus_GraphicsDrawImage($PauseBuffer, $Bitmap, 0, 0)
	_GDIPlus_GraphicsFillRect($PauseBuffer, 0, 0, $Width, $Height, $hBrushDark)
	_GDIPlus_GraphicsDrawImage($PauseBuffer, $Pausebild, $x25, $Height / 2 - 37.5)
	_GDIPlus_GraphicsDrawImage($PauseBuffer, $imgBeenden, $Width - 20, 4)
	_GDIPlus_GraphicsDrawImageRect($Graphic, $PauseBitmap, 0, 0, $Width, $Height)

	Local $aMouseInfo = GUIGetCursorInfo($GUI1)
	If @error Then
		_MouseDownEvent(0)
		Return $ST_paused
	ElseIf _MouseDownEvent($aMouseInfo[2]) Then
		If $aMouseInfo[0] > 280 And $aMouseInfo[0] < 296 And $aMouseInfo[1] > 4 And $aMouseInfo[1] < 20 Then
			ende()
		Else
			For $i = 0 To 84 Step 2
				_GDIPlus_GraphicsDrawImageRect($PauseBuffer, $Bitmap, 0, 0, $Width, $Height)
				_GDIPlus_GraphicsFillRect($PauseBuffer, 0, 0, $Width, $Height, $hBrushDark)
				_GDIPlus_GraphicsDrawImage($PauseBuffer, $pause_up, $x25, $y25 - $i)
				_GDIPlus_GraphicsDrawImage($PauseBuffer, $pause_down, $x25, $y26 + $i)
				_GDIPlus_GraphicsDrawImage($PauseBuffer, $imgBeenden, $Width - 20, 4)
				_GDIPlus_GraphicsDrawImageRect($Graphic, $PauseBitmap, 0, 0, $Width, $Height)
				Sleep(0)
			Next
			_GDIPlus_GraphicsDrawImage($PauseBuffer, $Pause_eraenzung, $x25, $y25 - $i + 22)
			_GDIPlus_GraphicsDrawImage($PauseBuffer, $play_again, $x25 + 10, 170)
			_GDIPlus_GraphicsDrawImage($PauseBuffer, $menu, $x25 + 10, 250)
			_GDIPlus_GraphicsDrawImage($PauseBuffer, $imgBeenden, $Width - 20, 4)
			_GDIPlus_GraphicsDrawImageRect($Graphic, $PauseBitmap, 0, 0, $Width, $Height)
			Return $ST_pause_menu
		EndIf

	EndIf
	If Not $paused Then Return $ST_playing
	Return $ST_paused
EndFunc   ;==>_DrawPause_CheckInput

Func _DrawPauseMenu_CheckInput()
	Local $i = 84
	_GDIPlus_GraphicsDrawImageRect($PauseBuffer, $Bitmap, 0, 0, $Width, $Height)
	_GDIPlus_GraphicsFillRect($PauseBuffer, 0, 0, $Width, $Height, $hBrushDark)
	_GDIPlus_GraphicsDrawImage($PauseBuffer, $pause_up, $x25, $y25 - $i)
	_GDIPlus_GraphicsDrawImage($PauseBuffer, $pause_down, $x25, $y26 + $i)
	_GDIPlus_GraphicsDrawImage($PauseBuffer, $Pause_eraenzung, $x25, $y25 - $i + 22)
	_GDIPlus_GraphicsDrawImage($PauseBuffer, $play_again, $x25 + 10, 170)
	_GDIPlus_GraphicsDrawImage($PauseBuffer, $menu, $x25 + 10, 250)
	_GDIPlus_GraphicsDrawImage($PauseBuffer, $imgBeenden, $Width - 20, 4)
	_GDIPlus_GraphicsDrawImageRect($Graphic, $PauseBitmap, 0, 0, $Width, $Height)

	If Not $paused Then Return $ST_playing
	Local $aMouseInfo = GUIGetCursorInfo($GUI1)
	If @error Then
		_MouseDownEvent(0)
		Return $ST_pause_menu
	ElseIf _MouseDownEvent($aMouseInfo[2]) Then
		Select
			Case $aMouseInfo[0] > 99 And $aMouseInfo[0] < 203 And $aMouseInfo[1] > 172 And $aMouseInfo[1] < 208
				$paused = 0
				_NewGame()
				Return $ST_playing
			Case $aMouseInfo[0] > 97 And $aMouseInfo[0] < 202 And $aMouseInfo[1] > 252 And $aMouseInfo[1] < 288
				$paused = 0
				Return $ST_main_menu
			Case $aMouseInfo[0] > 280 And $aMouseInfo[0] < 296 And $aMouseInfo[1] > 4 And $aMouseInfo[1] < 20
				ende()
		EndSelect
	EndIf

	Return $ST_pause_menu
EndFunc   ;==>_DrawPauseMenu_CheckInput

Func _DrawGameOver_CheckInput()
	If $scoreplus > $aScores[5][0] Then Return $ST_enter_score
	_GDIPlus_GraphicsDrawImage($Buffer, $Gameover, 0, 0)
	_GDIPlus_GraphicsDrawString($Buffer, "Dein Score: " & $scoreplus, 24, 185, "Comic Sans MS", 12)
	_GDIPlus_GraphicsDrawImage($Buffer, $imgBeenden, $Width - 20, 4)
;~ 	_GDIPlus_GraphicsDrawImageRect($Graphic, $Bitmap, 0, 0, $Width, $Height)
	_WinAPI_RedrawWindow($GUI1, 0, 0, $RDW_INTERNALPAINT)
	Local $aMouseInfo = GUIGetCursorInfo($GUI1)
	If @error Then
		_MouseDownEvent(0)
		Return $ST_game_over
	ElseIf _MouseDownEvent($aMouseInfo[2]) Then
		Select
			Case $aMouseInfo[0] > 91 And $aMouseInfo[0] < 195 And $aMouseInfo[1] > 230 And $aMouseInfo[1] < 257
				_NewGame()
				Return $ST_playing
			Case $aMouseInfo[0] > 152 And $aMouseInfo[0] < 258 And $aMouseInfo[1] > 293 And $aMouseInfo[1] < 329
				Return $ST_main_menu
			Case $aMouseInfo[0] > 280 And $aMouseInfo[0] < 296 And $aMouseInfo[1] > 4 And $aMouseInfo[1] < 20
				ende()
		EndSelect
	EndIf
	Return $ST_game_over
EndFunc   ;==>_DrawGameOver_CheckInput

Func _DrawEnterScore_CheckInput()
	Local Static $fInitDone = False, $Input, $ReadName
	If Not $fInitDone Then
		$ReadName = StringLeft(IniRead($datapath, "Optionen", "LastPlayer", "Spieler"), 9)
		$Input = GUICtrlCreateInput($ReadName, 79, 227)
		GUICtrlSetLimit($Input, 9)
		$fInitDone = True
	EndIf
	_GDIPlus_GraphicsClear($Buffer, 0x00000000)
	_GDIPlus_GraphicsDrawImage($Buffer, $Newhighscore, 0, 0)
	_GDIPlus_GraphicsDrawString($Buffer, "Dein Score: " & $scoreplus, 24, 205, "Comic Sans MS", 12)
	_GDIPlus_GraphicsDrawString($Buffer, "Name: ", 24, 225, "Comic Sans MS", 12)
;~ 	_GDIPlus_GraphicsDrawImageRect($Graphic, $Bitmap, 0, 0, $Width, $Height)
	_WinAPI_RedrawWindow($GUI1, 0, 0, $RDW_INTERNALPAINT)

	Local $aMouseInfo = GUIGetCursorInfo($GUI1)
	If @error Then
		_MouseDownEvent(0)
		Return $ST_game_over
	ElseIf _MouseDownEvent($aMouseInfo[2]) Then
		If $aMouseInfo[0] > 96 And $aMouseInfo[0] < 205 And $aMouseInfo[1] > 261 And $aMouseInfo[1] < 301 Then
			$Name = StringLeft(StringStripWS(GUICtrlRead($Input), 7), 9)
			If $Name = "" Then $Name = "Spieler"
			$aScores[5][0] = $scoreplus
			$aScores[5][1] = $Name
			_ArraySort($aScores, 1, 1, 0, 0)
			_WriteScores($aScores)
			IniWrite($datapath, "Optionen", "LastPlayer", $Name)
			$fInitDone = False
			GUICtrlDelete($Input)

			_NewGame()
			Return $ST_playing
		ElseIf $aMouseInfo[0] > 149 And $aMouseInfo[0] < 259 And $aMouseInfo[1] > 323 And $aMouseInfo[1] < 358 Then
			$Name = StringLeft(StringStripWS(GUICtrlRead($Input), 7), 9)
			If $Name = "" Then $Name = "Spieler"
			$aScores[5][0] = $scoreplus
			$aScores[5][1] = $Name
			_ArraySort($aScores, 1, 1, 0, 0)
			_WriteScores($aScores)
			IniWrite($datapath, "Optionen", "LastPlayer", $Name)
			$fInitDone = False
			GUICtrlDelete($Input)

			Return $ST_main_menu
		EndIf
	EndIf
	Return $ST_enter_score
EndFunc   ;==>_DrawEnterScore_CheckInput

Func _WriteScores($aScores)
	Local $hash = Binary('')
	For $i = 1 To UBound($aScores) - 1
		$aScores[$i][0] = _Crypt_EncryptData(StringToBinary($aScores[$i][0], 4), $hScoreKey, $CALG_USERKEY)
		$aScores[$i][1] = _Crypt_EncryptData(StringToBinary(StringLeft($aScores[$i][1], 9), 4), $hScoreKey, $CALG_USERKEY)
		$hash &= $aScores[$i][0] & $aScores[$i][1]
	Next
	IniWriteSection($datapath, "Scores", $aScores)
	IniWrite($datapath, "Optionen", "ScoreHash", _Crypt_HashData($hash, $CALG_SHA1))
EndFunc   ;==>_WriteScores
Func _DecryptScores(ByRef $aScores, Const ByRef $ScoreHash)
	; Author: ProgAndy
	If Not IsArray($aScores) Then Dim $aScores[6][2] = [[0]]
	If UBound($aScores) <> 6 Then ReDim $aScores[6][2]
	Local $hash = Binary('')
	For $i = 1 To $aScores[0][0]
		$aScores[$i][0] = Binary($aScores[$i][0])
		$aScores[$i][1] = Binary($aScores[$i][1])
		$hash &= $aScores[$i][0] & $aScores[$i][1]
	;~ 	$aScores[$i][0] = Number($aScores[$i][0])
		$aScores[$i][0] = Number(BinaryToString(_Crypt_DecryptData($aScores[$i][0], $hScoreKey, $CALG_USERKEY), 4))
		$aScores[$i][1] = StringLeft(BinaryToString(_Crypt_DecryptData($aScores[$i][1], $hScoreKey, $CALG_USERKEY), 4), 9)
	Next
	If _Crypt_HashData($hash, $CALG_SHA1) <> $ScoreHash Then Dim $aScores[6][2] = [[0]]
	_ArraySort($aScores, 1, 1, 0, 0)
EndFunc


Func _DrawGame_CheckInput()
	If $paused Then Return $ST_paused
	Local $AlterDoodle = $AktuellerDoodle
	If $movement = 0 Then
		$aktualpos = MouseGetPos()
		If $aktualpos[0] < $Width / 2 Then
			$MoveSpeed = ($aktualpos[0] - $Width / 2) / 3
			Select
				Case $huton = 0 And $raketeon = 0 And $Sprungf = 0
					$AktuellerDoodle = $Doodle_Links
				Case $raketeon = 1
					$AktuellerDoodle = $DoodleRakl
				Case $huton = 1
					$AktuellerDoodle = $DoodleHutl
				Case $Sprungf = 1
					$AktuellerDoodle = $Doodle_sf_l

			EndSelect


		EndIf
		If $aktualpos[0] > 0 and $aktualpos[0] < $Width And $aktualpos[1] > 0 And $aktualpos[1] < $Height Then
		If $aktualpos[0] > $Width / 2 Then
			$MoveSpeed = ($aktualpos[0] - $Width / 2) / 3
			Select
				Case $huton = 0 And $raketeon = 0 And $Sprungf = 0
					$AktuellerDoodle = $Doodle_Rechts
				Case $raketeon = 1
					$AktuellerDoodle = $DoodleRakr
				Case $huton = 1
					$AktuellerDoodle = $DoodleHutr
				Case $Sprungf = 1
					$AktuellerDoodle = $Doodle_sf_r
			EndSelect
		EndIf
		EndIf
		If _IsPressed("02", $dll) Then
			$MoveSpeed = 0
		EndIf

	Else
		If _IsPressed("25", $dll) Then
			$MoveSpeed -= 2
			Select
				Case $huton = 0 And $raketeon = 0 And $Sprungf = 0
					$AktuellerDoodle = $Doodle_Links
				Case $raketeon = 1
					$AktuellerDoodle = $DoodleRakl
				Case $huton = 1
					$AktuellerDoodle = $DoodleHutl
				Case $Sprungf = 1
					$AktuellerDoodle = $Doodle_sf_l
			EndSelect
		EndIf
		If _IsPressed("27", $dll) Then
			$MoveSpeed += 2
			Select
				Case $huton = 0 And $raketeon = 0 And $Sprungf = 0
					$AktuellerDoodle = $Doodle_Rechts
				Case $raketeon = 1
					$AktuellerDoodle = $DoodleRakr
				Case $huton = 1
					$AktuellerDoodle = $DoodleHutr
				Case $Sprungf = 1
					$AktuellerDoodle = $Doodle_sf_r
			EndSelect
		EndIf
	EndIf
	Select
		Case $x + $Doodle_Width - $DOODLE_BORDER < 0
			$x = $Width - $DOODLE_BORDER
		Case $x + $DOODLE_BORDER > $Width
			$x = -$Doodle_Width + $DOODLE_BORDER
		Case $MoveSpeed > 30
			$MoveSpeed = 30
		Case $MoveSpeed < -30
			$MoveSpeed = -30
	EndSelect
	$i += $JumpSpeed
	If Not ($AlterDoodle = $AktuellerDoodle) Then
		Local $AlteDoodle_Height = $Doodle_Height
		$Doodle_Height = _GDIPlus_ImageGetHeight($AktuellerDoodle)
		$y -= ($Doodle_Height - $AlteDoodle_Height)
	EndIf


	$platnotactive = 0
	$platactive = 0
	$yalt = $y
	$platold = $plat
	If $huton = 0 And $raketeon = 0 and not $letdie Then
		$t += $Zeitschrit
;~ 		MsgBox(0, "", $wintermod)
;~ 		If $wintermod = 1 Then


;~ 			If $yboden = $y + 10 Then
;~ 				$y = $yboden - $Doodle_Height - Round(Abs($sprungkraft * $t - ($grav / 2) * $t ^ 2))
;~ 			Else
;~ 				$y = $yboden - $Doodle_Height - Round($sprungkraft * $t - ($grav / 2) * $t ^ 2)
;~ 			EndIf
;~ 		Else
		If $yboden = $y + 30 Then
			$y = $yboden - $Doodle_Height - 10 - Round(Abs($sprungkraft * $t - ($grav / 2) * $t ^ 2))
		Else
			$y = $yboden - $Doodle_Height - 10 - Round($sprungkraft * $t - ($grav / 2) * $t ^ 2)
		EndIf
;~ 		EndIf

$Platmovespeed = ($Height -50 - $yboden)/20
If $Sprungf And $sprung Then
	$Platmovespeed = 7
ElseIf $Sprungf Then
	$Platmovespeed += 3
ElseIf $sprung = 1 Then
	$Platmovespeed += 5
Elseif $yboden > $Height -50 Then
	$move = 1
	$Platmovespeed = 0
EndIf
	If $untersprung = 1 Then
	$Platmovespeed = 14
EndIf

$ybodenalt = $yboden


;~ 				Select
;~ 					Case $y < 0
;~ 						$Platmovespeed = 14

;~ 					Case $y < 220 And $y > 180
;~ 						$move = 1
;~ 						$Platmovespeed = 1

;~ 					Case $y < 180
;~ 						$Platmovespeed = 4
;~ 					Case $y > 180
;~ 						$Platmovespeed = 0
;~ 					Case $y >= 220
;~ 						$move = 0
;~ 						$Platmovespeed = 0
;~ 				EndSelect
;~ 			EndIf
EndIf

;---------------------------------------------------------------------Monster--------------------------------------------------------
;~ If $scoreplus > 40000 Then
	Switch $Mobexist
		Case 1
			If $coordcheck = False Then
			$coordold = $coord1
			$coordcheck = True
			EndIf
			If $coord1 = $coordold or $coord1 = $coordold + 6 Then
				$moveright *=  -1
			EndIf
			$coord1 += $moveright
			Mobcheck()

		Case 2
			If $coordcheck = False Then
			$coordold = $coord1
			$coordcheck = True
			EndIf
			If $coord1 = $coordold or $coord1 = $coordold + 6 Then
				$moveright = $moveright * -1
			EndIf
			$coord1 += $moveright
			Mobcheck()

		Case 3
			If $mobset = 0 Then
			If $coordcheck = False Then
				$coord3 = $coord2+33
				$coordcheck = True
			EndIf
			Mobcheck()
			EndIf


		Case 4
			If $coordcheck = False Then
				$coordold = $coord2
				$coordcheck = True
			EndIf
			If $coord2 = $coordold or $coord2 = $coordold - 6 Then
				$moveright = $moveright *-1
			EndIf
			$coord2 -= 2
			If $mobtimeron = False Then
				$mobtimeron = True
				$mobtimer = TimerInit()
			EndIf
			$mobdiff = TimerDiff($mobtimer)
			If $mobdiff >= $change Then
				$change += 150
				$aktuellerMob = Eval("Flug" & $Bild)
				;MsgBox(0,"",$aktuellerMob)
				$Bild += 1
				If $Bild > 2 Then
					$Bild = 1
				EndIf
			EndIf
			If $coord2 < -100 Then
				$Mobexist = 0
			EndIf
			Mobcheck()

		Case 5
			If $coord1 > 261 or $coord1 < 39 Then
				$moveright = $moveright *-1
			EndIf
			If $moveright < 0 Then
				$aktuellerMob = $MoveMobl
			Else
				$aktuellerMob = $MoveMobr
			EndIf
			$coord1 += $moveright

			If $coordcheck = False Then
				$coordold = $coord2
				$choordcheck = True
			EndIf

			$coordold += $Platmovespeed
			If $coord2 > $coordold +5 or $coord2 < $coordold Then
				$moveup = $moveup *-1
			EndIf
			$coord2 += $moveup
			Mobcheck()

		Case 6
			If $ufoset = 0 Then
			If $coordcheck = False Then
			$coordold = $coord1
			$coordcheck = True
		EndIf
			If $coord1 <= $coordold or $coord1 >= $coordold + 5 Then
				$moveright *=  -1
			EndIf
			EndIf
			$coord1 += $moveright
			Mobcheck(96)

		Case 7
			If $coordcheck = False Then
			$coordold = $coord1
			$coordcheck = True
			EndIf
			If $coord1 = $coordold or $coord1 > $coordold + $Width/3 Then
				$moveright *=  -1
			EndIf
			$coord1 += $moveright

			Mobcheck()
		Case -1
			If $setloch = 0 Then
				If not $protected And(($coord1 <= $x + $Doodle_Width - $DOODLE_BORDER And $coord1 + $mobwidth >= $x + $Doodle_Width) or ($coord1 <= $x And $coord1 + $mobwidth >= $x) or ($coord1 >= $x And $coord1 + $mobwidth <= $x + $Doodle_Width)) And (($y <= $coord2 + $mobheight  And $y + $Doodle_Height >= $coord2 + $mobheight) or ($y <= $coord2  And $y + $Doodle_Height >= $coord2 + $mobheight)) Then
					$letdie = 1
				EndIf
			EndIf
		Case 8
			If $coordcheck = False Then
				$coordold = $coord2
				$coordcheck = True
			EndIf
			If $coord1 <= 10 or $coord1 >= $Width-10-$mobwidth Then
				$moveright = $moveright *-1
			EndIf
			$coord2 -= 2
			$coord1 += $moveright
			If $mobtimeron = False Then
				$mobtimeron = True
				$mobtimer = TimerInit()
			EndIf
			$mobdiff = TimerDiff($mobtimer)
			If $mobdiff >= $change Then
				$change += 150
				$aktuellerMob = Eval("Flug2" & $Bild)
				;MsgBox(0,"",$aktuellerMob)
				$Bild += 1
				If $Bild > 2 Then
					$Bild = 1
				EndIf
			EndIf
			If $coord2 < -150 Then
				$Mobexist = 0
			EndIf
			Mobcheck()

		Case 0
			CreateMob()

	EndSwitch


	$coord2 += $Platmovespeed
	$coord3 += $Platmovespeed
	If $coord2 > 460 Then
		$Mobexist = 0
	EndIf
;~ 	EndIf

	;-----------------------------------------------------------------Schuss--------------------------------------------------------------------------

	Local $aMouseInfo = GUIGetCursorInfo($GUI1)
	If @error Then
		_MouseDownEvent(0)
	ElseIf _MouseDownEvent($aMouseInfo[2]) Then
		If $AktuellerDoodle <> $Doodle_Schuss Then $aAktuellerDoodle = $AktuellerDoodle

		$geschossen = 1
		If $DirectionalShooting Then
		If $aMouseInfo[1] < $y Then
			$mouseX = $aMouseInfo[0] - $x - 27
			$mouseY = $y - $aMouseInfo[1]
			$verhX = $mouseX / $mouseY

			$mBewegY = Sqrt( (10^2) / (1+ ($verhX^2) ) )
			$mBewegX = $mBewegY*$verhX

			If UBound($schuss) = 1 Then
			_Array2DAdd($schuss, $x+27.5&"|"&$y-11&"|"&$mBewegX&"|"&$mBewegY)
		EndIf
		_Array2DAdd($schuss, $x+27.5&"|"&$y-11&"|"&$mBewegX&"|"&$mBewegY)

			EndIf
		Else
			$mBewegX = 0
			$mBewegY = 10
			If UBound($schuss) = 1 Then
			_Array2DAdd($schuss, $x+27.5&"|"&$y-11&"|"&$mBewegX&"|"&$mBewegY)
		EndIf
		_Array2DAdd($schuss, $x+27.5&"|"&$y-11&"|"&$mBewegX&"|"&$mBewegY)
		EndIf
	EndIf
	If $geschossen > 0 Then
	$geschossen += 1
	EndIf
	If $geschossen >= 15 Then
	$geschossen = 0
	$AktuellerDoodle = $aAktuellerDoodle
	EndIf
	If $geschossen < 15 And $geschossen > 0 Then
	If $DirectionalShooting And $aMouseInfo[1] < $y Then $AktuellerDoodle = $Doodle_Schuss
	If not $DirectionalShooting Then $AktuellerDoodle = $Doodle_Schuss
	EndIf





		For $n = 2 to UBound($schuss) - 1
			$schuss[$n][1] += $Platmovespeed
	$schuss[$n][1] -= $schuss[$n][3]
	$schuss[$n][0] += $schuss[$n][2]
			If $schuss[$n][1] < -100 Then
			_ArrayDelete($schuss, $n)
			ExitLoop
		Else


		EndIf
		If $Mobexist > 0 Then
			If ($coord1 <= $schuss[$n][0] And $coord1 +$mobwidth>= $schuss[$n][0]) And ($schuss[$n][1] >= $coord2 And $schuss[$n][1] - 15 <= $coord2 + $mobheight) Then
				$mobdead -= 1
				If $mobdead = 0 Then $Mobexist = 0
				_ArrayDelete($schuss, $n)
				ExitLoop
			EndIf
			EndIf
		Next





			If $huton = 0 And $raketeon = 0 and not $letdie Then
		For $n = 0 To UBound($gruen_n, 1) - 1 Step 1

			If $gruen_n[$n][3] = 7 Then $gruen_n[$n][3] = 6

			If $untersprung = 0 Then
				Local $range = 10, $change = $sprungkraft * $t - ($grav / 2) * $t ^ 2
				If $change < -10 Then $range = _Min(-$change, 40)
				If $gruen_n[$n][2] = 6 Then
					$multip = 2
				Else
					$multip = 1
					EndIf
				Select
					Case ($gruen_n[$n][0] <= $x + $Doodle_Width - $DOODLE_BORDER And $gruen_n[$n][0] + $Plat_Width*$multip >= $x + $DOODLE_BORDER) And ($y + $Doodle_Height - $range <= $gruen_n[$n][1] And $y + $Doodle_Height >= $gruen_n[$n][1])
						If $yalt + 1 < $y Then
							If $gruen_n[$n][2] = 3 Then
								$braunf[$n] = 1
								If not $soundoff Then _SoundPlay($sBreak)
							Else
								If $gruen_n[$n][2] = 4 Then
									If $weisweg[$n] = 0 Then



										$onplatform = 1
										$plat = $n
										$t = 0
										$t = $Zeitschrit
										$yboden = $gruen_n[$n][1]
										$platten += 1
									EndIf
								ElseIf $gruen_n[$n][2] = 5 Then
									If $rotweg[$n] = 0 Then
										$onplatform = 1
										$plat = $n
										$t = 0
										$t = $Zeitschrit
										$yboden = $gruen_n[$n][1]
										$platten += 1
									EndIf
								Else
									$onplatform = 1
									$plat = $n
									$t = 0
									$t = $Zeitschrit
									$yboden = $gruen_n[$n][1]
									$platten += 1

								EndIf

								If $platold < $plat Or ($platold = 16 And $plat = 0) Then
									$scoreplus += 100
								EndIf
								If $gruen_n[$n][3] = 1 Then
									If $AktuellerDoodle = $Doodle_Links Then
										$AktuellerDoodle = $DoodleHutl
									Else
										$AktuellerDoodle = $DoodleHutr
									EndIf
									$gruen_n[$n][3] = 0
									$huton = 1
								EndIf
								If $gruen_n[$n][3] = 2 Then
									If $AktuellerDoodle = $Doodle_Rechts Then
										$AktuellerDoodle = $DoodleRakr
									Else
										$AktuellerDoodle = $DoodleRakl
									EndIf
									$gruen_n[$n][3] = 0
									$raketeon = 1
								EndIf
								If $sprung = 1 Then
									$sprung = 0
									$sprungkraft /= 1.5
								EndIf
								If $sprungtr = 1 Then
									$fSprung = 0
									$sprungtr = 0
									$sprungkraft /= 2
								EndIf

								If $gruen_n[$n][3] = 8 and not $protected Then
									$protected = 1
									$gruen_n[$n][3] = 0
								EndIf

								If $gruen_n[$n][3] = 3 Then
									If ($gruen_n[$n][0] + $federpos[$n] - $Doodle_Width + $DOODLE_BORDER <= $x And $gruen_n[$n][0] + $federpos[$n] + 17 >= $x + $DOODLE_BORDER) Then
										If $soundoff = 0 Then _SoundPlay($sSprung)
										$gruen_n[$n][3] = 4
										$sprung = 1
										$sprungkraft *= 1.5
									EndIf
								EndIf
								If $gruen_n[$n][3] = 6 Then

									$gruen_n[$n][3] = 7
									$sprungtr = 1
									$sprungkraft *= 2
								EndIf


								If $Sprungf = 0 Then
									If $gruen_n[$n][3] = 5 Then

										If $AktuellerDoodle = $Doodle_Rechts Then
											$AktuellerDoodle = $Doodle_sf_gesch_r
										Else
											$AktuellerDoodle = $Doodle_sf_gesch_l
										EndIf

										$gruen_n[$n][3] = 0
										$sprungkraft *= 1.4
										$Sprungf = 1
									EndIf
								EndIf
								If $Sprungf = 1 Then

									If $AktuellerDoodle = $Doodle_sf_r Then
										$AktuellerDoodle = $Doodle_sf_gesch_r
									Else
										$AktuellerDoodle = $Doodle_sf_gesch_l
									EndIf

									If $Sprungnu = 6 Then

										$Sprungf = 0
										$Sprungnu = 0
										$sprungkraft /= 1.4
										If $AktuellerDoodle = $Doodle_sf_gesch_r Then
											$AktuellerDoodle = $Doodle_Rechts
										Else
											$AktuellerDoodle = $Doodle_Links
										EndIf
									Else
										If not ($letzeplatte = $n) Then
											$letzeplatte = $n
										$Sprungnu += 1
										EndIf
									EndIf

								EndIf
								If $soundoff = 0 And $rotweg[$n] = 0 And $weisweg[$n] = 0 Then
									If $sprung = 0 And $Sprungf = 0 Then _SoundPlay($sJump)
									If $Sprungf = 1 Then _SoundPlay($sSf)
									If $sprungtr = 1 Then _SoundPlay($sTrampolin)
									If $sprung = 1 Then _SoundPlay($sSprung)
								EndIf
								If $gruen_n[$n][2] = 4 Then

									$weisweg[$n] = 1
								EndIf

							EndIf
						EndIf


				EndSelect
			EndIf
		Next

	EndIf
	If $untereplatte = 1 Then
		If $y + $Doodle_Height > $Height - 20 And $y + $Doodle_Height < $Height Then
			If $soundoff = 0 Then _SoundPlay($sJump)
			$yboden = $Height
			$t = 0
			$t = $Zeitschrit
			$untereplatte = 1
		EndIf
	EndIf



;~ For $n = 0 to Ubound(

	$x += $MoveSpeed * $t / 10
	If $raketeon = 0 And $huton = 0 Then
		If $ybodenalt > $yboden Then $scoreplus += Abs(($yboden - $ybodenalt))
	EndIf
;~
	If $y + 5 > $Height Then $die = True


	If $huton = 1 Then
		$plus = 15
	ElseIf $raketeon = 1 Then
		$plus = 30
	Else
		$plus = 10
	EndIf
$scoreplus = Round($scoreplus, -1)

	If $scoreplus > $score Then
		$score += $plus
	EndIf


	;======================HUT
	If $huton = 1 Then

		If $timeron = 0 Then
			If $soundoff = 0 Then _SoundPlay($sPropeller, 0)
			$scoreplus += 1500
			$huttimer = _Timer_Init()
			$timeron = 1
			$tnorm = $t
			$t = $hutt
		EndIf
		$Platmovespeed = 6
		$time = _Timer_Diff($huttimer)

		If $hutbild = 0 Then
			If $AktuellerDoodle = $DoodleHutl Then
				$AktuellerDoodle = $DoodleHutl1
			ElseIf $AktuellerDoodle = $DoodleHutr Then
				$AktuellerDoodle = $DoodleHutr1

			EndIf
			$hutbild = 1
		Else
			If $AktuellerDoodle = $DoodleHutl1 Then
				$AktuellerDoodle = $DoodleHutl
			ElseIf $AktuellerDoodle = $DoodleHutr1 Then
				$AktuellerDoodle = $DoodleHutr
			EndIf
			$hutbild = 0
		EndIf



		If $time >= 3000 Then
			$t = $tnorm
			$huton = 0
			$timeron = 0
			If $AktuellerDoodle = $DoodleHutr Then
				$AktuellerDoodle = $Doodle_Rechts
			Else
				$AktuellerDoodle = $Doodle_Links
			EndIf

		EndIf
	EndIf

	;=========================Protection
	If $protected Then
		If not $protectiontimer Then
			$ptimer = _Timer_Init()
			$protectiontimer = 1
		EndIf

		If _Timer_Diff($ptimer) > 10000 Then
		$protected = 0
		$protectiontimer = 0
		EndIf
	EndIf

	;=========================Rakete
	If $raketeon = 1 Then

		If $timerrakon = 0 Then
			If $soundoff = 0 Then _SoundPlay($sRakete, 0)
			$scoreplus += 3000
			$raketentimer = _Timer_Init()
			$timerrakon = 1
			$tnorm = $t
			$t = $hutt
			If $AktuellerDoodle = $Doodle_Rechts Then
				$AktuellerDoodle = $DoodleRakr
			Else
				$AktuellerDoodle = $DoodleRakl
			EndIf
		EndIf
		$Platmovespeed = 15
		$time = _Timer_Diff($raketentimer)




		If $time >= 3000 Then
			$raketeon = 0
			$timerrakon = 0
			$t = $tnorm
			If $AktuellerDoodle = $DoodleRakr Then
				$AktuellerDoodle = $Doodle_Rechts
			Else
				$AktuellerDoodle = $Doodle_Links
			EndIf

		EndIf
	EndIf


;~ 	$Doodle_Height = _GDIPlus_ImageGetHeight($AktuellerDoodle)
;~ 	$Doodle_Width = _GDIPlus_ImageGetWidth($AktuellerDoodle)




	If $fSprung = 0 Then
		If $sprungtr = 1 Then
			If $Angle = 360 Then
				$Angle = 0
				$untersprung = 0
				$fSprung = 1
			Else
				$untersprung = 1
				$Angle += 15
			EndIf
		EndIf
	EndIf

If $letdie Then
			If $dAngle = 360 Then
				$dAngle = 0
				$letdie = 0
				$die = True
			Else
				$dAngle += 30
			EndIf
		EndIf


	If $move = 1 Then
		$untereplatte = 0
		If $huton = 0 And $raketeon = 0 and not $letdie Then
			$yboden += $Platmovespeed
		EndIf
		For $n = 0 To UBound($gruen_n) - 1
			$gruen_n[$n][1] += $Platmovespeed
			If $gruen_n[$n][2] = 1 Then
				Select
					Case $gruen_n[$n][0] <= 30
						$bewegrichtung[$n] = 1
					Case $gruen_n[$n][0] + $Plat_Width >= $Width - 30
						$bewegrichtung[$n] = 0
				EndSelect

				If $bewegrichtung[$n] = 1 Then
					$gruen_n[$n][0] += 3
				Else
					$gruen_n[$n][0] -= 3
				EndIf
			EndIf
;~ MsgBox(0, "", $braunf[$n])
			If $gruen_n[$n][2] = 2 Then
				If Abs($bewegh[$n]) >= 32 Then
					If $vbewegrichtung[$n] = 1 Then
						$vbewegrichtung[$n] = 0
					Else
						$vbewegrichtung[$n] = 1
					EndIf
				EndIf



				If $vbewegrichtung[$n] = 1 Then
					$gruen_n[$n][1] += 2
					$bewegh[$n] += 2
				Else
					$gruen_n[$n][1] -= 2
					$bewegh[$n] -= 2
				EndIf
			EndIf
			If $gruen_n[$n][2] = 2 Then
				If $gruen_n[$n][1] - $bewegh[$n] > $Height + 50 Then
					reset($n)
				EndIf
			Else
				If $gruen_n[$n][1] - $bewegh[$n] > $Height Then
					reset($n)
				EndIf
			EndIf




		Next

	EndIf

;~ MsgBox(0, "", $MoveSpeed)

;~     _GDIPlus_GraphicsClear($Buffer, 0xFFFFFFFF)
;~ 	_WinAPI_RedrawWindow($GUI1, "", "", $RDW_UPDATENOW + $RDW_FRAME)

	_GDIPlus_GraphicsDrawImage($Buffer, $Background, 0, 0)



	If $Angle = 0 Then
		$nAktuellerDoodle = $AktuellerDoodle
	EndIf




	For $n = 0 To UBound($gruen_n, 1) - 1
		Switch $gruen_n[$n][3]
			Case 1
				_GDIPlus_GraphicsDrawImage($Buffer, $Hut, $gruen_n[$n][0], $gruen_n[$n][1] - 23)
			Case 2
				_GDIPlus_GraphicsDrawImage($Buffer, $Rakete, $gruen_n[$n][0], $gruen_n[$n][1] - 37)
			Case 3
				_GDIPlus_GraphicsDrawImage($Buffer, $Federzu, $gruen_n[$n][0] + $federpos[$n], $gruen_n[$n][1] - $Federz_Height)
			Case 4
				_GDIPlus_GraphicsDrawImage($Buffer, $Federoffen, $gruen_n[$n][0] + $federpos[$n], $gruen_n[$n][1] - $Federo_Height)
			Case 5
				_GDIPlus_GraphicsDrawImage($Buffer, $sf_schuhe, $gruen_n[$n][0], $gruen_n[$n][1] - 21)
			Case 6
				_GDIPlus_GraphicsDrawImage($Buffer, $Trampolin, $gruen_n[$n][0] + 15, $gruen_n[$n][1] - 14)
			Case 7
				_GDIPlus_GraphicsDrawImage($Buffer, $Trampolin1, $gruen_n[$n][0] + 15, $gruen_n[$n][1] - 14)
			Case 8
				_GDIPlus_GraphicsDrawImageRect($Buffer, $protection ,$gruen_n[$n][0], $gruen_n[$n][1] - 30, 30, 30)

		EndSwitch

		Switch $gruen_n[$n][2]
			Case 0
				_GDIPlus_GraphicsDrawImage($Buffer, $Platform_gruen, $gruen_n[$n][0], $gruen_n[$n][1])
			Case 6
				_GDIPlus_GraphicsDrawImage($Buffer, $Platform_gruen, $gruen_n[$n][0], $gruen_n[$n][1])
				_GDIPlus_GraphicsDrawImage($Buffer, $Platform_gruen, $gruen_n[$n][0]+$Plat_Width, $gruen_n[$n][1])
			Case 1
				_GDIPlus_GraphicsDrawImage($Buffer, $Platform_hellblau, $gruen_n[$n][0], $gruen_n[$n][1])
			Case 2
				_GDIPlus_GraphicsDrawImage($Buffer, $Platform_grau, $gruen_n[$n][0], $gruen_n[$n][1])
			Case 3
				If $braunf[$n] = 1 Or $bei90grad[$n] Then
					If $bAngle[$n] = 90 Then
						$bAngle[$n] = 0
						$braunf[$n] = 0
						$bei90grad[$n] = 1
					Else
						$bAngle[$n] += 10
					EndIf
					If $bei90grad[$n] = 1 Then
						$gruen_n[$n][1] += 7.5
						$brAngle = 90
					Else

						$brAngle = $bAngle[$n]
						If $brAngle > 0 Then
							$gruen_n[$n][1] += 7.5
						EndIf

					EndIf


					_GDIPlus_GraphicsTranslateTransform($Buffer, $gruen_n[$n][0], $gruen_n[$n][1] + 7.5)
					_GDIPlus_GraphicsRotateTransform($Buffer, $brAngle)
;~ 							MsgBox(0,"1", $bAngle[$n]&$n)
					_GDIPlus_GraphicsDrawImage($Buffer, $Platform_braun1, 0, -7.5)
					_GDIPlus_GraphicsResetTransform($Buffer)
					_GDIPlus_GraphicsTranslateTransform($Buffer, $gruen_n[$n][0] + 57, $gruen_n[$n][1] + 7.5)
					_GDIPlus_GraphicsRotateTransform($Buffer, $brAngle * - 1)
					_GDIPlus_GraphicsDrawImage($Buffer, $Platform_braun2, -31, -7.5)
					_GDIPlus_GraphicsResetTransform($Buffer)
				Else
					_GDIPlus_GraphicsDrawImage($Buffer, $Platform_braun, $gruen_n[$n][0], $gruen_n[$n][1])
				EndIf



			Case 4

				If $weisweg[$n] = 1 Then
					If $wtrans[$n] < 250 Then
						$wtrans[$n] += 25
					EndIf
				EndIf
				_GDIPlus_GraphicsDrawImageRectRectTrans($Buffer, $Platform_weis, 0, 0, "", "", $gruen_n[$n][0], $gruen_n[$n][1], "", "", 2, $wtrans[$n])

			Case 5
				If $gruen_n[$n][2] = 5 Then
					If $gruen_n[$n][1] > 60 And $gro60[$n] = 0 Then
						$gelbweg[$n] = 1
						$gro60[$n] = 1
					EndIf

				EndIf
				If $gelbweg[$n] = 1 Then
					$gtrans[$n] += 6
				EndIf
				If $gtrans[$n] > 254 Then
					$gtrans[$n] = 0
					$gelbweg[$n] = 0
					$rotweg[$n] = 1

				EndIf
				If $rotweg[$n] = 1 Then
					$rotweg[$n] = -5

				EndIf


				If $rotweg[$n] < -2 Then

					_GDIPlus_GraphicsDrawImage($Buffer, $Explusion, $gruen_n[$n][0] - 4, $gruen_n[$n][1] - 4)
					If $soundoff = 0 And $soundplaye[$n] = 0 Then
						_SoundPlay($sExpl)
						$soundplaye[$n] = 1

					EndIf
					$rotweg[$n] += 1

				EndIf

				If $rotweg[$n] = 0 Then
					_GDIPlus_GraphicsDrawImageRect($Buffer, $Platform_rot, $gruen_n[$n][0], $gruen_n[$n][1], 57, 16)
					_GDIPlus_GraphicsDrawImageRectRectTrans($Buffer, $Platform_gelb, 0, 0, "", "", $gruen_n[$n][0], $gruen_n[$n][1], "", "", 2, $gtrans[$n])
				EndIf

		EndSwitch

	Next



;-----------------------------------------------------------------------------------------Mobs 2----------------------------------------------------------------------
	Switch $Mobexist
	Case 1
		_GdiPlus_GraphicsDrawImage($Buffer,$Monster_Gruen,$coord1,$coord2)
	Case 2
		_GdiPlus_GraphicsDrawImage($Buffer,$Monster_Lila,$coord1,$coord2)
    Case 3
		If $mobset = 0 Then _GdiPlus_GraphicsDrawImage($Buffer,$Yeti,$coord1,$coord2+5)


	Case 4
		_GdiPlus_GraphicsDrawImage($Buffer,$aktuellerMob,$coord1,$coord2)
	Case 5
		_GdiPlus_GraphicsDrawImage($Buffer,$aktuellerMob,$coord1,$coord2)
	Case 6
		If $ufoset = 0 or $bosmon = 1 Then
		_GdiPlus_GraphicsDrawImage($Buffer,$ufo,$coord1,$coord2)
		$aPoints[0][0] = 4
		$aPoints[1][0] = $coord1+20
		$aPoints[1][1] = $coord2+30
		$aPoints[2][0] = $coord1+60
		$aPoints[2][1] = $coord2+30
		$aPoints[3][0] = $coord1+80
		$aPoints[3][1] = $coord2+132
		$aPoints[4][0] = $coord1
		$aPoints[4][1] = $coord2+132
		_GDIPlus_GraphicsFillPolygon($Buffer, $aPoints, $hBrushSchein)
		EndIf
		If $bosmon = 1 Then
			_GdiPlus_GraphicsDrawImage($Buffer,$ufo,$coord1+80,$coord2)
			$aPoints[0][0] = 4
			$aPoints[1][0] = $coord1+100
			$aPoints[1][1] = $coord2+30
			$aPoints[2][0] = $coord1+140
			$aPoints[2][1] = $coord2+30
			$aPoints[3][0] = $coord1+160
			$aPoints[3][1] = $coord2+132
			$aPoints[4][0] = $coord1+80
			$aPoints[4][1] = $coord2+132
			_GDIPlus_GraphicsFillPolygon($Buffer, $aPoints, $hBrushSchein)
			_GdiPlus_GraphicsDrawImage($Buffer,$ufo,$coord1+160,$coord2)
			$aPoints[0][0] = 4
			$aPoints[1][0] = $coord1+180
			$aPoints[1][1] = $coord2+30
			$aPoints[2][0] = $coord1+220
			$aPoints[2][1] = $coord2+30
			$aPoints[3][0] = $coord1+240
			$aPoints[3][1] = $coord2+132
			$aPoints[4][0] = $coord1+160
			$aPoints[4][1] = $coord2+132
			_GDIPlus_GraphicsFillPolygon($Buffer, $aPoints, $hBrushSchein)
		EndIf
	Case 7
		_GdiPlus_GraphicsDrawImage($Buffer, $rotermob, $coord1,$coord2)
	Case -1
		If $setloch = 0 Then _GdiPlus_GraphicsDrawImage($Buffer, $loch, $coord1,$coord2)
	Case 8
		_GdiPlus_GraphicsDrawImage($Buffer,$aktuellerMob,$coord1,$coord2)





EndSwitch
;~ MsgBox(0, "", $Mobexist)

;----------------------------------------------------------------------------------------Schuss----------------------------------------------------------------------

If UBound($schuss) >= 3 Then
For $n = 2 To UBound($schuss)-1
	_GdiPlus_GraphicsDrawImage($Buffer,$Kugel,$schuss[$n][0],$schuss[$n][1])
Next
Endif
If $protected Then _GDIPlus_GraphicsDrawImageRect($Buffer, $protect, $x+$Doodle_Width/2 - $Protect_Width/2, $y+$Doodle_Height/2 - $Protect_Height/2, 100, 100)



If $sprungtr = 1 And $fSprung = 0 Then
		_GDIPlus_GraphicsTranslateTransform($Buffer, $x + $Doodle_Width / 2, $y + $Doodle_Height / 2)
		If $nAktuellerDoodle = $Doodle_Links Then
			_GDIPlus_GraphicsRotateTransform($Buffer, $Angle)
			_GDIPlus_GraphicsDrawImage($Buffer, $AktuellerDoodle, $Doodle_Width / 2 * - 1, $Doodle_Height / 2 * - 1)
		Else
			_GDIPlus_GraphicsRotateTransform($Buffer, $Angle * - 1)
			_GDIPlus_GraphicsDrawImage($Buffer, $AktuellerDoodle, $Doodle_Width / 2 * - 1, $Doodle_Height / 2 * - 1)
		EndIf
		_GDIPlus_GraphicsResetTransform($Buffer)
	Elseif $letdie Then
	_GDIPlus_GraphicsTranslateTransform($Buffer, $x + $Doodle_Width / 2, $y + $Doodle_Height / 2)
		If $nAktuellerDoodle = $Doodle_Links Then
			_GDIPlus_GraphicsRotateTransform($Buffer, $dAngle)
			_GDIPlus_GraphicsDrawImageRect($Buffer, $AktuellerDoodle, $Doodle_Width / 2 * - 1, $Doodle_Height / 2 * - 1, $Doodle_Width*($dAngle/360 - 1)*-1, $Doodle_Height*($dAngle/360 - 1)*-1)
		Else
			_GDIPlus_GraphicsRotateTransform($Buffer, $dAngle * - 1)
			_GDIPlus_GraphicsDrawImageRect($Buffer, $AktuellerDoodle, $Doodle_Width / 2 * - 1, $Doodle_Height / 2 * - 1, $Doodle_Width*($dAngle/360 - 1)*-1, $Doodle_Height*($dAngle/360 - 1)*-1)
		EndIf
		_GDIPlus_GraphicsResetTransform($Buffer)
	Else
		_GDIPlus_GraphicsDrawImage($Buffer, $AktuellerDoodle, $x, $y)
	EndIf

If $die Then
		If Not $soundoff Then _SoundPlay($sFall)
		Return $ST_game_over
	EndIf
	_GDIPlus_GraphicsDrawImage($Buffer, $Punkteleiste, 0, 0)
	;_GDIPlus_GraphicsDrawImageRectRectTrans($Buffer, $Punkteleiste, 0, 0, "", "", "", "", "", "", 2, 50)
	_GDIPlus_GraphicsDrawString($Buffer, Round($score, 0), 5, 5, "Comic Sans MS", 15)
	_WinAPI_RedrawWindow($GUI1, 0, 0, $RDW_INTERNALPAINT)
;~ 	_GDIPlus_GraphicsDrawImageRect($Graphic, $Bitmap, 0, 0, $Width, $Height)

	If $die Then
		If Not $soundoff Then _SoundPlay($sFall)
		Return $ST_game_over
	EndIf
	Return $ST_playing

EndFunc   ;==>_DrawGame_CheckInput

Func Mobcheck($scheinheight = 0)
	If (($coord1 <= $x + $Doodle_Width - $DOODLE_BORDER And $coord1 + $mobwidth >= $x + $Doodle_Width) or ($coord1 <= $x And $coord1 + $mobwidth >= $x) or ($coord1 >= $x And $coord1 + $mobwidth <= $x + $Doodle_Width)) And (($y <= $coord2 + $mobheight + $scheinheight  And $y + $Doodle_Height >= $coord2 + $mobheight + $scheinheight) or ($y <= $coord2  And $y + $Doodle_Height >= $coord2 + $mobheight)) and not $protected Then
		$die = True
	EndIf
	If (($coord1 <= $x + $Doodle_Width - $DOODLE_BORDER And $coord1 + $mobwidth >= $x + $Doodle_Width) or ($coord1 <= $x And $coord1 + $mobwidth >= $x) or ($coord1 >= $x And $coord1 + $mobwidth <= $x + $Doodle_Width)) And ($y + $Doodle_Height <= $coord2 And $y + $Doodle_Height + 15 >= $coord2) Then
		If not $soundoff Then _SoundPlay($sJumpOnMon)
		If $yalt + 1 < $y Then
			$t = $Zeitschrit
			$yboden = $coord2
			$Mobexist = 0
			If $sprung = 1 Then
				$sprung = 0
				$sprungkraft /= 1.5
			EndIf
								If $sprungtr = 1 Then
									$fSprung = 0
									$sprungtr = 0
									$sprungkraft /= 2
								EndIf
								If $Sprungf = 1 Then

									If $AktuellerDoodle = $Doodle_sf_r Then
										$AktuellerDoodle = $Doodle_sf_gesch_r
									Else
										$AktuellerDoodle = $Doodle_sf_gesch_l
									EndIf

									If $Sprungnu = 6 Then
										$Sprungf = 0
										$Sprungnu = 0
										$sprungkraft = 50
										If $AktuellerDoodle = $Doodle_sf_gesch_r Then
											$AktuellerDoodle = $Doodle_Rechts
										Else
											$AktuellerDoodle = $Doodle_Links
										EndIf
									Else
										$Sprungnu += 1
									EndIf

			EndIf
			$sprung = 1
			$sprungkraft *= 1.5
		EndIf
	EndIf
EndFunc ;===Mobcheck



Func reset($n)
;~ 	If $gruen_n[$n][2] = 6 Then
;~ 		_ArrayDelete($gruen_n, $n)
;~ 		Return
;~ 	EndIf

	$bei90grad[$n] = 0
	$braunf[$n] = 0
	$wtrans[$n] = 1
	$gtrans[$n] = 1
	$soundplaye[$n] = 0
	$gro60[$n] = 0
	$rotweg[$n] = 0
	$gelbweg[$n] = 0
	$weisweg[$n] = 0
	$bewegh[$n] = 0
	$gruen_n[$n][0] = Random(0, $Width - $Plat_Width, 1)
	$gruen_n[$n][1] = $gruen_n[$zuletztresetet][1] - $bewegh[$zuletztresetet] + $abstand

	Switch $scoreplus
		Case 0 To 10000
			Local $perc[6] = [60, 20, 10, 10, 0, 0]
;~ 			$r = Random(0, 10, 1)
		Case 10000 To 20000
;~ 			$r = Random(0, 8, 1)
			Local $perc[6] = [50, 20, 10, 10, 10, 0]
		Case 20000 To 30000
;~ 			$r = Random(0, 6, 1)
			Local $perc[6] = [35, 15, 15, 15, 10, 10]
		Case 30000 To 40000
;~ 			$r = Random(0, 4, 1)
			Local $perc[6] = [20, 20, 20, 20, 10, 10]
		Case Else
			Local $perc[6] = [20, 20, 20, 20, 10, 10]
;~ 			$r = Random(0, 3, 1)
	EndSwitch

	$gruen_n[$n][2] = 0
	Switch Random(1, 100, 1)
		Case 0 To $perc[0]
			$gruen_n[$n][2] = 0
		Case $perc[0] To $perc[0] + $perc[1]
			$gruen_n[$n][2] = 1
		Case $perc[0] + $perc[1] To $perc[0] + $perc[1] + $perc[2]
			$gruen_n[$n][2] = 2
		Case $perc[0] + $perc[1] + $perc[2] To $perc[0] + $perc[1] + $perc[2] + $perc[3]
			If (Not $gruen_n[$zuletztresetet][2] = 3) Then $gruen_n[$n][2] = 3
		Case $perc[0] + $perc[1] + $perc[2] + $perc[3] To $perc[0] + $perc[1] + $perc[2] + $perc[3] + $perc[4]
			$gruen_n[$n][2] = 4
		Case Else
			If (Not $gruen_n[$zuletztresetet][2] = 5) Then $gruen_n[$n][2] = 5
	EndSwitch


;~ 	If $r = 1 Then
;~ 		$gruen_n[$n][2] = 1
;~ 	ElseIf $r = 2 Then
;~ 		$gruen_n[$n][2] = 2
;~ 	Else
;~ 		$gruen_n[$n][2] = 0
;~ 	EndIf
;~ 	$r = Random(0, 5, 1)
;~ 	If $r = 2 and (Not $gruen_n[$zuletztresetet][2] = 3) Then
;~ 		$gruen_n[$n][2] = 3
;~ 	ElseIf $r = 3 Then
;~ 		$gruen_n[$n][2] = 4
;~ 	ElseIf $r = 4 and (Not $gruen_n[$zuletztresetet][2] = 5) Then
;~ 		$gruen_n[$n][2] = 5
;~ 	EndIf

	If $scoreplus >= $punktelimit Then
		$abstand -= 3
		$punktelimit = $punktelimit + ($punktelimit + 1000)
	EndIf
	If $mobset = 1 Then
		$mobset = 0
		$gruen_n[$n][2]=6
		$gruen_n[$n][0] = Random(0, $Width - $Plat_Width*2, 1)
		$choordcheck = False
			$coord1 = $gruen_n[$n][0]
			$coord2 = $gruen_n[$n][1]-37
			$coord3 = 0
			$mobdead = 3

	EndIf

	If $ufoset = 1 Then
		$gruen_n[$n][2] = 0
		$coord1 = $gruen_n[$n][0] + $Plat_Width/2 - 40
			$coord2 = $gruen_n[$n][1]-132
			$mobdead = 1
			$ufoset = 0
		EndIf


	If $setloch = 1 Then
		$gruen_n[$n][2]=0
		$r = Random(0,1,1)
		If $r = 1 Then
			If $gruen_n[$zuletztresetet][0] > $Width/2 Then
		$gruen_n[$n][0] = Random(0, $Width/2 - $Plat_Width, 1)
		$choordcheck = False
			$coord1 = Random($Width/2 , $Width - $mobwidth,1)
			$coord2 = $gruen_n[$n][1]-$mobheight/2
		$setloch = 0
		EndIf
	ElseIf $gruen_n[$zuletztresetet][0]-$Plat_Width < $Width/2 Then
	$gruen_n[$n][0] = Random($Width/2,  $Width - $Plat_Width, 1)
		$choordcheck = False
			$coord1 = Random(0 , $Width/2 - $mobwidth,1)
			$coord2 = $gruen_n[$n][1]-$mobheight/2
		$setloch = 0
	EndIf


	EndIf





	$gruen_n[$n][3] = 0
	If $Sprungf = 0 Then
		If (Not $gruen_n[$n][2] = 3) or (Not $gruen_n[$n][2] = 4) Then
			$r = Random(0, 100, 1)
			If $r = 3 Then $gruen_n[$n][3] = 1
			If $r = 6 Then $gruen_n[$n][3] = 2
			$r = Random(0, 50, 1)
			If $r = 3 Then
				$gruen_n[$n][3] = 3
					$federpos[$n] = Random(7, $Plat_Width - 17, 1)
			EndIf
			;============== $gruen_n[$n][3] = 4 <== wird gebraucht Nicht benutzen!
			If $r = 4 Then $gruen_n[$n][3] = 5
			If $r = 5 Then $gruen_n[$n][3] = 6
			;============== $gruen_n[$n][3] = 7 <== wird gebraucht Nicht benutzen!
			If $r = 6 Then $gruen_n[$n][3] = 8
		EndIf
	EndIf
;~ 	$r = Random(0, 5,1)
;~ 	If $r = 1 Then  $gruen_n[$n][3] = 3
	$zuletztresetet = $n
EndFunc   ;==>reset

Func MY_WM_PAINT($hWnd, $uMsg, $wParam, $lParam)
	If $hWnd = $GUI1 Then _GDIPlus_GraphicsDrawImageRect($Graphic, $Bitmap, 0, 0, $Width, $Height)
	Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_PAINT
Func MY_WM_ACTIVATEAPP($hWnd, $uMsg, $wParam, $lParam)
	$gfWeAreActive = ($wParam = 1)
	Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_ACTIVATEAPP

Func _pause()
	$paused = Not $paused
EndFunc   ;==>_pause

Func _NewGame()
	Global $braunf[17], $bAngle[17], $weisweg[13], $gro60[13], $bei90grad[17], $AktuellerDoodle = $Doodle_Rechts, $protected = 0, $sprungtr,  $Mobexist = 0, $schuss[1][4], $explodiert[13], $soundplaye[13], $gelbweg[13], $rotweg[13], $wtrans[13], $gtrans[13], $image1, $bewegh[20]
	Global $federpos[20], $ReadN[5], $gruen_n[13][4], $untereplatte = 1, $hutt = 3, $tnorm, $grav = 9.81, $untersprung = 0, $nAktuellerDoodle = 0, $fSprung = 0, $Angle = 0, $sprung = 0, $sprungkraft = 50, $Sprungf = 0, $Sprungnu = 0
	Global $zuletztresetet = 12
	Global $punktelimit = 1000, $abstand = -40, $paused = 0, $die = False, $i = 0, $t = 0, $y = $Height - $Doodle_Height, _
			$onplatform = 0, $t1 = 0, $normpos, $huttimer, $ybodenalt, $hutbild = 0, $x25 = $Width / 2 - 64, $y25 = $Height / 2 - 37.5
	Global $plat = 0, $raketeon = 0, $timerrakon = 0, $raketentimer = 0, $move = 0, $score = 0, $scoreplus = 0, $yboden = $Height, $Platmovespeed = 0, $platten = 0, $huton = 0, $nAngle = 0, $timeron = 0, $Sprungnu = 0


	Global $bewegrichtung[17] = [Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), _
			Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), _
			Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1)]

	Global $vbewegrichtung[17] = [Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), _
			Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1), _
			Random(0, 1, 1), Random(0, 1, 1), Random(0, 1, 1)]

	For $n = 0 To 19
		$bewegh[$n] = 0
	Next


	$gruen_n[0][0] = 200
	$gruen_n[1][0] = 150
	For $n = 0 To UBound($gruen_n) - 1
		If (Not $n = 0 Or $n = 1) Then
			$gruen_n[$n][0] = Random(0, $Width - $Plat_Width, 1)
		EndIf
		$bAngle[$n] = 0
		$braunf[$n] = 0
		$explodiert[$n] = 0
		$gelbweg[$n] = 0
		$gro60[$n] = 0
		$rotweg[$n] = 0
		$gtrans[$n] = 1
		$wtrans[$n] = 1
		$gruen_n[$n][1] = 400 + ($n * $abstand) ;$abstand ist Negativ!!!!!!
		$gruen_n[$n][2] = 0
		$gruen_n[$n][3] = 0
	Next

	$x = $gruen_n[0][0]
	$y = $Height - $Doodle_Height

	$die = False
	$t = 0
	$plat = 0
	$MoveSpeed = 0
	$move = 0
	$Platmovespeed = 0
	$platten = 0
	$score = 0
	$scoreplus = 0
	If $gruen_n[0][0] < 60 + $Doodle_Width And $gruen_n[0][0] + $Plat_Width > 60 + $Doodle_Width Then
		$x = $Width - 60
	Else
		$x = 60
	EndIf
EndFunc   ;==>_NewGame

Func ende()
	Exit
EndFunc   ;==>ende
Func CleanOnExit()
	; Author: ProgAndy
	_GDIPlus_ImageDispose($MoveMobl)
	_GDIPlus_ImageDispose($MoveMobr)
	_GDIPlus_ImageDispose($Flug3)
	_GDIPlus_ImageDispose($Flug2)
	_GDIPlus_ImageDispose($Flug1)
	_GDIPlus_ImageDispose($Yeti)
	_GDIPlus_ImageDispose($Monster_Lila)
	_GDIPlus_ImageDispose($Monster_Gruen)
	_GDIPlus_ImageDispose($Kugel)
	_GDIPlus_ImageDispose($Rakete)
	_GDIPlus_ImageDispose($Newhighscore)
	_GDIPlus_ImageDispose($Gameover)
	_GDIPlus_ImageDispose($Scorebackground)
	_GDIPlus_ImageDispose($Hut)
	_GDIPlus_ImageDispose($Pausebild)
	_GDIPlus_ImageDispose($Optionscreen)
	_GDIPlus_ImageDispose($Federzu)
	_GDIPlus_ImageDispose($Federoffen)
	_GDIPlus_ImageDispose($sf_schuhe)
	_GDIPlus_ImageDispose($Trampolin)
	_GDIPlus_ImageDispose($Trampolin1)
	_GDIPlus_ImageDispose($pause_up)
	_GDIPlus_ImageDispose($pause_down)
	_GDIPlus_ImageDispose($menu)
	_GDIPlus_ImageDispose($play_again)
	_GDIPlus_ImageDispose($Pause_eraenzung)
	_GDIPlus_ImageDispose($Platform_weis)
	_GDIPlus_ImageDispose($Background)
	_GDIPlus_ImageDispose($Start)
	_GDIPlus_ImageDispose($DoodleHutl)
	_GDIPlus_ImageDispose($DoodleHutr)
	_GDIPlus_ImageDispose($DoodleHutl1)
	_GDIPlus_ImageDispose($DoodleHutr1)
	_GDIPlus_ImageDispose($Punkteleiste)
	_GDIPlus_ImageDispose($Platform_gruen)
	_GDIPlus_ImageDispose($Platform_hellblau)
	_GDIPlus_ImageDispose($Doodle_Rechts)
	_GDIPlus_ImageDispose($Doodle_Links)
	_GDIPlus_ImageDispose($DoodleRakl)
	_GDIPlus_ImageDispose($DoodleRakr)
	_GDIPlus_ImageDispose($Doodle_sf_r)
	_GDIPlus_ImageDispose($Doodle_sf_l)
	_GDIPlus_ImageDispose($Doodle_sf_gesch_l)
	_GDIPlus_ImageDispose($Doodle_sf_gesch_r)
	_GDIPlus_ImageDispose($Platform_grau)
	_GDIPlus_ImageDispose($Platform_braun1)
	_GDIPlus_ImageDispose($Platform_braun2)

	_GDIPlus_FontDispose($hFont)
	_GDIPlus_FontFamilyDispose($hFamily)
	_GDIPlus_StringFormatDispose($hFormat)

	_GDIPlus_GraphicsDispose($PauseBuffer)
	_GDIPlus_BitmapDispose($PauseBitmap)

	_GDIPlus_GraphicsDispose($Graphic)
	_GDIPlus_GraphicsDispose($Buffer)
	_GDIPlus_BitmapDispose($Bitmap)

	_GDIPlus_BrushDispose($hBrushDark)
	_GDIPlus_BrushDispose($hBrushOptOff)
	_GDIPlus_BrushDispose($hBrushOptOn)

	_GDIPlus_Shutdown()


	_SoundClose($sPropeller)
	_SoundClose($sFall)
	_SoundClose($sJump)
	_SoundClose($sRakete)
	_SoundClose($sSprung)
	_SoundClose($sSf)
	_SoundClose($sTrampolin)
	_SoundClose($sExpl)
	_SoundClose($sJumpOnMon)
	_SoundClose($sBreak)

	_Crypt_Shutdown()
	IniWrite($datapath, "Optionen", "Wintermode", $wintermod)
EndFunc   ;==>CleanOnExit

Func _LoadSkin($sName = "")
	; Author: ProgAndy


	If $sName = "nooby" Then
;~ 		MsgBox(0,"Nooby", "Nooby Mode")
		$NoobyMod = True
	EndIf

	If ($sName = "" Or $sName = "default") Then
		$sName = ''
	Else
		$sName &= "\"
	EndIf


	_LoadImage($Start, $sName, "Start")
	_LoadImage($Optionscreen, $sName, "Optionen")
	_LoadImage($Scorebackground, $sName, "Bestenliste")
	_LoadImage($Gameover, $sName, "Gameover")
	_LoadImage($Newhighscore, $sName, "Neuer_Highscore")
	_LoadImage($Background, $sName, "Hintergrund")
	_LoadImage($Punkteleiste, $sName, "Punkteleiste")

	_LoadImage($Kugel, $sName, "Kugel")
	_LoadImage($Monster_Gruen, $sName, "Grünes wackelmonster")
	_LoadImage($Monster_Lila, $sName, "Lila Monster")
	_LoadImage($Yeti, $sName, "Yeti Monster")
	_LoadImage($Flug1, $sName, "Flug Monster 1")
	_LoadImage($Flug2, $sName, "Flug Monster 2")
	_LoadImage($Flug3, $sName, "Flug Monster 3")
	_LoadImage($Flug21, $sName, "Flug21")
	_LoadImage($Flug22, $sName, "Flug22")
	_LoadImage($MoveMobr, $sName, "MoveMob")
	_LoadImage($MoveMobl, $sName, "MoveMobl")
	_LoadImage($ufo, $sName, "Ufo")
	_LoadImage($rotermob, $sName, "monsterrot")
	_LoadImage($loch, $sName, "Loch")


	_LoadImage($imgBeenden, $sName, "Beenden")
	_LoadImage($menu, $sName, "menu")
	_LoadImage($play_again, $sName, "play_again")


	_LoadImage($Pausebild, $sName, "Pause")
	_LoadImage($pause_up, $sName, "Pause oben")
	_LoadImage($pause_down, $sName, "Pause unten")
	_LoadImage($Pause_eraenzung, $sName, "Pause Menu")


	_LoadImage($Hut, $sName, "Hut")
	_LoadImage($Rakete, $sName, "Rakete")
	_LoadImage($sf_schuhe, $sName, "Federschuhe")
	_LoadImage($protection, $sName, "Protection")
	_LoadImage($protect, $sName, "Protect")
	_LoadImage($Trampolin, $sName, "Trampolin")
	_LoadImage($Trampolin1, $sName, "Trampolin benutzt")
	_LoadImage($Federzu, $sName, "Feder zu")
	_LoadImage($Federoffen, $sName, "Feder offen")
	$Federz_Height = _GDIPlus_ImageGetHeight($Federzu)
	$Federo_Height = _GDIPlus_ImageGetHeight($Federoffen)
	$Protect_Height = _GDIPlus_ImageGetHeight($protect)
	$Protect_Width = _GDIPlus_ImageGetWidth($protect)



	_LoadImage($Doodle_Rechts, $sName, "Doodle Rechts")
	_LoadImage($Doodle_Links, $sName, "Doodle Links")
	Global $Doodle_Height = _GDIPlus_ImageGetHeight($Doodle_Rechts)
	Global $Doodle_Width = _GDIPlus_ImageGetWidth($Doodle_Rechts)
	_LoadImage($DoodleHutl, $sName, "Doodle Hut Links 1")
	_LoadImage($DoodleHutr, $sName, "Doodle Hut Rechts 1")
	_LoadImage($DoodleHutl1, $sName, "Doodle Hut Links 2")
	_LoadImage($DoodleHutr1, $sName, "Doodle Hut Rechts 2")
	_LoadImage($DoodleRakl, $sName, "Doodle Rakete Links")
	_LoadImage($DoodleRakr, $sName, "Doodle Rakete Rechts")
	_LoadImage($Doodle_sf_r, $sName, "Doodle Feder Rechts")
	_LoadImage($Doodle_sf_l, $sName, "Doodle Feder Links")
	_LoadImage($Doodle_sf_gesch_l, $sName, "Doodle Feder Gespannt Links")
	_LoadImage($Doodle_sf_gesch_r, $sName, "Doodle Feder Gespannt Rechts")
	_LoadImage($Doodle_Schuss, $sName, "Doodle Schuss")
	$Doodle_sf_Height = _GDIPlus_ImageGetHeight($Doodle_sf_r)
	$Doodle_sf_gesch_Height = _GDIPlus_ImageGetHeight($Doodle_sf_gesch_l)

	_LoadImage($Platform_weis, $sName, "Plattform weis")
	_LoadImage($Platform_gruen, $sName, "Plattform grün")
	_LoadImage($Platform_hellblau, $sName, "Plattform hellblau")
	_LoadImage($Platform_grau, $sName, "Plattform grau")
	_LoadImage($Platform_braun1, $sName, "Plattform Braun Links")
	_LoadImage($Platform_braun, $sName, "Plattform Braun")
	_LoadImage($Platform_braun2, $sName, "Plattform Braun Rechts")
	_LoadImage($Platform_rot, $sName, "Plattform Rot")
	_LoadImage($Platform_gelb, $sName, "Plattform Gelb")
	_LoadImage($Explusion, $sName, "Explosion")

	$Plat_Width = _GDIPlus_ImageGetWidth($Platform_gruen)

EndFunc   ;==>_LoadSkin

Func _LoadImage(ByRef $hImage, $sMod, $sImage)
	; Author: ProgAndy
	If $hImage Then _GDIPlus_ImageDispose($hImage)
	Local $aFiles[4] = [$sMod & $sImage & '.png', $sMod & $sImage & '.gif', $sImage & '.png', $sImage & '.gif']
	For $i = 0 To 3
		If FileExists($gsImagePath & $aFiles[$i]) Then
			$hImage = _GDIPlus_ImageLoadFromFile($gsImagePath & $aFiles[$i])
			If $hImage Then Return
		EndIf
	Next
EndFunc   ;==>_LoadImage


Func _GDIPlus_ImageAttributesSetWrapMode($hImageAttributes, $iWrapMode, $iARGB = 0xFF000000)
	Local $aResult = DllCall($ghGDIPdll, "uint", "GdipSetImageAttributesWrapMode", "hwnd", $hImageAttributes, "int", $iWrapMode, "uint", $iARGB, "int", 0)

	If @error Then Return SetError(@error, @extended, False)
	$GDIP_STATUS = $aResult[0]
	Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_ImageAttributesSetWrapMode

Func _GDIPlus_GraphicsDrawImageRectRectTrans($hGraphics, $hImage, $iSrcX, $iSrcY, $iSrcWidth = "", $iSrcHeight = "", _
		$iDstX = "", $iDstY = "", $iDstWidth = "", $iDstHeight = "", $iUnit = 2, $nTrans = 1)
	Local $tColorMatrix, $x, $hImgAttrib, $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
	If $iSrcWidth = 0 Or $iSrcWidth = "" Then $iSrcWidth = $iW
	If $iSrcHeight = 0 Or $iSrcHeight = "" Then $iSrcHeight = $iH
	If $iDstX = "" Then $iDstX = $iSrcX
	If $iDstY = "" Then $iDstY = $iSrcY
	If $iDstWidth = "" Then $iDstWidth = $iSrcWidth
	If $iDstHeight = "" Then $iDstHeight = $iSrcHeight
	If $iUnit = "" Then $iUnit = 2
	;;create color matrix data
	$tColorMatrix = DllStructCreate("float[5];float[5];float[5];float[5];float[5]")
	;blending values:
	$x = DllStructSetData($tColorMatrix, 1, 1, 1) * DllStructSetData($tColorMatrix, 2, 1, 2) * DllStructSetData($tColorMatrix, 3, 1, 3) * _
			DllStructSetData($tColorMatrix, 4, $nTrans, 4) * DllStructSetData($tColorMatrix, 5, 1, 5)
	;;create an image attributes object and update its color matrix
	$hImgAttrib = DllCall($ghGDIPdll, "int", "GdipCreateImageAttributes", "ptr*", 0)
	$hImgAttrib = $hImgAttrib[1]
	DllCall($ghGDIPdll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", 1, _
			"int", 1, "ptr", DllStructGetPtr($tColorMatrix), "ptr", 0, "int", 0)
	;;draw image into graphic object with alpha blend
	DllCall($ghGDIPdll, "int", "GdipDrawImageRectRectI", "hwnd", $hGraphics, "hwnd", $hImage, "int", $iDstX, "int", _
			$iDstY, "int", $iDstWidth, "int", $iDstHeight, "int", $iSrcX, "int", $iSrcY, "int", $iSrcWidth, "int", _
			$iSrcHeight, "int", $iUnit, "ptr", $hImgAttrib, "int", 0, "int", 0)
	;;clean up
	DllCall($ghGDIPdll, "int", "GdipDisposeImageAttributes", "ptr", $hImgAttrib)
	Return
EndFunc   ;==>_GDIPlus_GraphicsDrawImageRectRectTrans

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_GraphicsRotateTransform
; Description ...: Updates the world transformation matrix of a Graphics object with the product of itself and a rotation matrix
; Syntax.........: _GDIPlus_GraphicsRotateTransform($hGraphics, $nAngle[, $iOrder = 0])
; Parameters ....: $hGraphics - Pointer to a Graphics object
;                  $nAngle    - The angle, in degrees, of rotation
;                  $iOrder    - Order of matrices multiplication:
;                  |0 - The rotation matrix is on the left
;                  |1 - The rotation matrix is on the right
; Return values .: Success      - True
;                  Failure      - False and either:
;                  |@error and @extended are set if DllCall failed
;                  |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: None
; Related .......: _GDIPlus_GraphicsMultiplyTransform
; Link ..........; @@MsdnLink@@ GdipRotateWorldTransform
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_GraphicsRotateTransform($hGraphics, $nAngle, $iOrder = 0)
	Local $aResult = DllCall($ghGDIPdll, "uint", "GdipRotateWorldTransform", "hwnd", $hGraphics, "float", $nAngle, "int", $iOrder)

	If @error Then Return SetError(@error, @extended, False)
	$GDIP_STATUS = $aResult[0]
	Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_GraphicsRotateTransform

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_GraphicsResetTransform
; Description ...: Sets the world transformation matrix of a Graphics object to the identity matrix
; Syntax.........: _GDIPlus_GraphicsResetTransform($hGraphics)
; Parameters ....: $hGraphics - Pointer to a Graphics object
; Return values .: Success      - True
;                  Failure      - False and either:
;                  |@error and @extended are set if DllCall failed
;                  |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: None
; Related .......: None
; Link ..........; @@MsdnLink@@ GdipResetWorldTransform
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_GraphicsResetTransform($hGraphics)
	Local $aResult = DllCall($ghGDIPdll, "uint", "GdipResetWorldTransform", "hwnd", $hGraphics)

	If @error Then Return SetError(@error, @extended, False)
	$GDIP_STATUS = $aResult[0]
	Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_GraphicsResetTransform

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_GraphicsTranslateTransform
; Description ...: Updates a Graphics object's world transformation matrix with the product of itself and a translation matrix
; Syntax.........: _GDIPlus_GraphicsTranslateTransform($hGraphics, $nDX, $nDY[, $iOrder = 0])
; Parameters ....: $hGraphics - Pointer to a Graphics object
;                  $nDX	  	  - Horizontal component of the translation
;                  $nDY	  	  - Vertical component of the translation
;                  $iOrder    - Order of matrices multiplication:
;                  |0 - The translation matrix is on the left
;                  |1 - The translation matrix is on the right
; Return values .: Success      - True
;                  Failure      - False and either:
;                  |@error and @extended are set if DllCall failed
;                  |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: None
; Related .......: None
; Link ..........; @@MsdnLink@@ GdipTranslateWorldTransform
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_GraphicsTranslateTransform($hGraphics, $nDX, $nDY, $iOrder = 0)
	Local $aResult = DllCall($ghGDIPdll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGraphics, "float", $nDX, "float", $nDY, "int", $iOrder)

	If @error Then Return SetError(@error, @extended, False)
	$GDIP_STATUS = $aResult[0]
	Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_GraphicsTranslateTransform

Func _MouseDownEvent($fDown = 0)
	; Author: ProgAndy
	Local Static $fSaved = 0
	Local $fState = $fSaved
	$fSaved = $fDown
	Return $fDown And ($fState <> $fDown)
EndFunc   ;==>_MouseDownEvent


Func CreateMob()
	Local $rand
	$bosmon = 0
	If Floor($scoreplus/100) > 1 Then
		$randmax = 500 - Floor($scoreplus/100)
	Else
		$randmax = 1
	EndIf
	$rand = Random(0,$randmax,1)
;~ $rand = 1
	If $rand = 1 Then
	$Mobexist = Random(-1,8,1)
;~ 	$Mobexist = -1
	Switch $Mobexist
		Case 1
			$mobwidth = _GDIPlus_ImageGetWidth($Monster_Gruen)
			$mobheight = _GDIPlus_ImageGetHeight($Monster_Gruen)
			$coordcheck = False
			$coord1 = Random(0,$Width - $mobwidth,1)
			$coord2 = -53
			$moveright = -2
			$mobdead = Random(1,2,1)
		Case 2
			$mobwidth = _GDIPlus_ImageGetWidth($Monster_Lila)
			$mobheight = _GDIPlus_ImageGetHeight($Monster_Lila)
			$coordcheck = False
			$coord1 = Random(0,$Width - $mobwidth,1)
			$coord2 = -49
			$moveright = -2
			$mobdead = Random(1,2,1)
		Case 3
			$mobset = 1
			$mobwidth = _GDIPlus_ImageGetWidth($Yeti)
			$mobheight = _GDIPlus_ImageGetHeight($Yeti)
		Case 4
			$mobwidth = _GDIPlus_ImageGetWidth($Flug1)
			$mobheight = _GDIPlus_ImageGetHeight($Flug1)
			$coordcheck = False
			$coord1 = Random(0,$Width - $mobwidth,1)
			$coord2 = -44
			$aktuellerMob = $Flug1
			$moveright = -2
			$change = 300
			$Bild = 1
			$mobtimeron = False
			$mobdead = Random(1,2,1)
		Case 5
			$mobwidth = _GDIPlus_ImageGetWidth($MoveMobl)
			$mobheight = _GDIPlus_ImageGetHeight($MoveMobl)
			$coordcheck = False
			$coord1 = Random(0,$Width - $mobwidth,1)
			$coord2 = -50
			$mobdead = Random(1,2,1)

			If $coord1 <= 130 Then
				$aktuellerMob = $MoveMobr
				$moveright = -3
			Else
				$aktuellerMob = $MoveMobl
				$moveright = 3
			EndIf
			$moveup = 3
		Case 6
			$rand = Random(0, 500, 1)
			If $rand = 469 Then
			$bosmon = 1
			$coord1 = 27.5
			$coord2 = -140
			$mobdead = 5
			$mobwidth = _GDIPlus_ImageGetWidth($ufo)*3
			$mobheight = _GDIPlus_ImageGetHeight($ufo)*3
			Else
			$ufoset = 1
			$mobwidth = _GDIPlus_ImageGetWidth($ufo)
			$mobheight = _GDIPlus_ImageGetHeight($ufo)
			EndIf
			$coordcheck = False
			$moveright = -0.1
		Case 7
			$mobwidth = _GDIPlus_ImageGetWidth($rotermob)
			$mobheight = _GDIPlus_ImageGetHeight($rotermob)
			$coordcheck = False
			$coord1 = Random(0,($Width - $Width/3 -$mobwidth),1)
			$coord2 = -53
			$moveright = -3
			$mobdead = Random(1,2,1)
		Case -1
			$setloch = 1
			$mobwidth = _GDIPlus_ImageGetWidth($rotermob)
			$mobheight = _GDIPlus_ImageGetHeight($rotermob)
			$coordcheck = False
		Case 8
			$mobwidth = _GDIPlus_ImageGetWidth($Flug21)
			$mobheight = _GDIPlus_ImageGetHeight($Flug21)
			$coordcheck = False
			$coord1 = 10
			$coord2 = -100
			$aktuellerMob = $Flug21
			$moveright = -2
			$change = 300
			$Bild = 1
			$mobtimeron = False
			$mobdead = Random(1,2,1)




	EndSwitch
	EndIf
EndFunc ;===MobCreate


Func _Array2DAdd(ByRef $avArray, $sValue='')
    If ( Not IsArray($avArray) ) Then
        SetError(1)
        Return 0
    EndIf
    Local $UBound2nd = UBound($avArray,2)
    If @error = 2 Then
        ReDim $avArray[UBound($avArray)+1]
        $avArray[UBound($avArray)-1] = $sValue
    Else
        Local $arValue
        ReDim $avArray[UBound($avArray)+1][$UBound2nd]
        If $sValue = '' Then
            For $i = 0 To $UBound2nd-2
                $sValue &= '|'
            Next
        EndIf
        $arValue = StringSplit($sValue, '|')
        If $arValue[0] <> $UBound2nd Then
            SetError(2)
            Return 0
        EndIf
        For $i = 0 To $UBound2nd-1
            $avArray[UBound($avArray)-1][$i] = $arValue[$i+1]
        Next
    EndIf
    Return -1
EndFunc ;==>_Array2DAdd

