GDI+ Spiel: AutoIt Arena Fight.

  • scheint nicht so einfach zu sein:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <GDIPlus.au3>
    #include "VectorMath.au3"
    #include <Misc.au3>
    #include <WinAPI.au3>
    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ; - Author: name22(http://www.autoit.de)

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    $iGUIWidth = 600
    $iGUIHeight = 400
    $nFPS = 50

    [/autoit] [autoit][/autoit] [autoit]

    $nSlowMotion = 5

    [/autoit] [autoit][/autoit] [autoit]

    $nFriction = 0.98

    [/autoit] [autoit][/autoit] [autoit]

    $nPlayerSpeedMax = 200
    $nAccelerationForce = 10

    [/autoit] [autoit][/autoit] [autoit]

    $nProjectileSpeedPlayer = 500
    $iCoolDownPlayer = 200

    [/autoit] [autoit][/autoit] [autoit]

    $nSlowMotionFuelMax = 100
    $nSlowMotionFuel = 100
    $nSlowMotionRefillSpeed = 8
    $nSlowMotionConsumptionSpeed = 20

    [/autoit] [autoit][/autoit] [autoit]

    $nLifeForcePlayer = 60
    $nHealthRegenSpeed = 1

    [/autoit] [autoit][/autoit] [autoit]

    $nDisplayWave = 3000

    [/autoit] [autoit][/autoit] [autoit]

    $nSleepTime = 1000 / $nFPS
    $nOffsetSleepTime = 0

    [/autoit] [autoit][/autoit] [autoit]

    $nFPS_Display = 0
    $nFPS_Average = 0
    $iCounter = 1
    $iWaveCounter = 1

    [/autoit] [autoit][/autoit] [autoit]

    $bNewGame = True
    $bNewWave = True

    [/autoit] [autoit][/autoit] [autoit]

    Global $hBitmapBG
    Global $pause = False

    [/autoit] [autoit][/autoit] [autoit]

    $nTimeMod = 1

    [/autoit] [autoit][/autoit] [autoit]

    $vUser32Dll = DllOpen("User32.dll")
    $vNTdll = DllOpen("ntdll.dll")

    [/autoit] [autoit][/autoit] [autoit]

    $tRectBorder = DllStructCreate($tagRECT)
    $tPoint = DllStructCreate($tagPOINT)
    DllStructSetData($tRectBorder, "Left", 0)
    DllStructSetData($tRectBorder, "Top", 0)
    DllStructSetData($tRectBorder, "Right", $iGUIWidth)
    DllStructSetData($tRectBorder, "Bottom", $iGUIHeight)

    [/autoit] [autoit][/autoit] [autoit]

    $tPrecSleep = DllStructCreate("int64 time;")
    $pPrecSleep = DllStructGetPtr($tPrecSleep)

    [/autoit] [autoit][/autoit] [autoit]

    $hWnd = GUICreate("AutoIt Arena Fight v1.0 - Author: name22(http://www.autoit.de)", $iGUIWidth, $iGUIHeight)
    GUISetCursor(16, 1, $hWnd)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    $hDC = _WinAPI_GetDC($hWnd)
    $hCDC_Buffer = _WinAPI_CreateCompatibleDC($hDC)
    $hGDI_Bitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iGUIWidth, $iGUIHeight)
    _WinAPI_SelectObject($hCDC_Buffer, $hGDI_Bitmap)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hCDC_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_BitBlt($hDC, 0, 0, $iGUIWidth, $iGUIHeight, $hCDC_Buffer, 0, 0, 0x00CC0020)

    [/autoit] [autoit][/autoit] [autoit]

    $hBrush_Enemy = _GDIPlus_BrushCreateSolid(0xFFFF0000)
    $hBrush_Player = _GDIPlus_BrushCreateSolid(0xFF0000FF)
    $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xFF000000)
    $hBrush_BG_Menu = _GDIPlus_BrushCreateSolid("0x" & Hex(200, 2) & "F0F0F0")
    $hBrush_ProjectileBG = _GDIPlus_BrushCreateSolid(0xFF000000)
    $hBrush_MenuTextNormal = _GDIPlus_BrushCreateSolid(0xFF000000)
    $hBrush_MenuTextHighlight = _GDIPlus_BrushCreateSolid(0xFF808080)
    $hBrush_LifeBar = _GDIPlus_BrushCreateSolid(0xFFFF0000)
    $hBrush_SlowMotionBar = _GDIPlus_BrushCreateSolid(0xFF0000FF)
    $hBrush_Announcement = _GDIPlus_BrushCreateSolid("0x" & Hex(200, 2) & "000000")

    [/autoit] [autoit][/autoit] [autoit]

    $hPen_Bar = _GDIPlus_PenCreate(0xFF000000, 2)
    $hPen_Cursor = _GDIPlus_PenCreate(0xFF505050, 2)

    [/autoit] [autoit][/autoit] [autoit]

    $hStringFormat = _GDIPlus_StringFormatCreate()
    $hFamily_SegoeUI = _GDIPlus_FontFamilyCreate("Segoe UI")
    $hFont_FPS = _GDIPlus_FontCreate($hFamily_SegoeUI, 7)
    $hFont_Menu = _GDIPlus_FontCreate($hFamily_SegoeUI, 20)
    $hFont_Announcement = _GDIPlus_FontCreate($hFamily_SegoeUI, 50)

    [/autoit] [autoit][/autoit] [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "FPS 000", $hFont_FPS, _GDIPlus_RectFCreate(), $hStringFormat)
    $tLayout_FPS = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_FPS, "X", $iGUIWidth - DllStructGetData($tLayout_FPS, "Width") - 3)
    DllStructSetData($tLayout_FPS, "Y", $iGUIHeight - DllStructGetData($tLayout_FPS, "Height"))
    DllStructSetData($tLayout_FPS, "Width", DllStructGetData($tLayout_FPS, "Width") + 3)

    [/autoit] [autoit][/autoit] [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "Continue", $hFont_Menu, _GDIPlus_RectFCreate(0, 100), $hStringFormat)
    $tLayout_Menu_Continue = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_Menu_Continue, "X", $iGUIWidth / 2 - DllStructGetData($tLayout_Menu_Continue, "Width") / 2)
    DllStructSetData($tLayout_Menu_Continue, "Width", DllStructGetData($tLayout_Menu_Continue, "Width") + 1)

    [/autoit] [autoit][/autoit] [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "Start", $hFont_Menu, _GDIPlus_RectFCreate(0, 100), $hStringFormat)
    $tLayout_Menu_Start = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_Menu_Start, "X", $iGUIWidth / 2 - DllStructGetData($tLayout_Menu_Start, "Width") / 2)
    DllStructSetData($tLayout_Menu_Start, "Width", DllStructGetData($tLayout_Menu_Start, "Width") + 1)

    [/autoit] [autoit][/autoit] [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "Quit", $hFont_Menu, _GDIPlus_RectFCreate(0, 150), $hStringFormat)
    $tLayout_Menu_Quit = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_Menu_Quit, "X", $iGUIWidth / 2 - DllStructGetData($tLayout_Menu_Quit, "Width") / 2)
    DllStructSetData($tLayout_Menu_Quit, "Width", DllStructGetData($tLayout_Menu_Quit, "Width") + 1)

    [/autoit] [autoit][/autoit] [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "Wave 1", $hFont_Announcement, _GDIPlus_RectFCreate(), $hStringFormat)
    $tLayout_Announcement = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_Announcement, "X", $iGUIWidth / 2 - DllStructGetData($tLayout_Announcement, "Width") / 2)
    DllStructSetData($tLayout_Announcement, "Y", $iGUIHeight / 2 - DllStructGetData($tLayout_Announcement, "Height") / 2)
    DllStructSetData($tLayout_Announcement, "Width", 0)
    DllStructSetData($tLayout_Announcement, "Height", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $nX_PlayerPos = Random(10, $iGUIWidth - 10)
    $nY_PlayerPos = Random(10, $iGUIHeight - 10)
    $nX_PlayerSpeed = 0
    $nY_PlayerSpeed = 0
    $nLifeForce = $nLifeForcePlayer

    [/autoit] [autoit][/autoit] [autoit]

    Global $aEnemys[1][6] = [[0]], $aProjectiles[1][6] = [[0]], $aAccelForce = _Vector_Create(0, 0), $nProjectileSpeedEnemy

    [/autoit] [autoit][/autoit] [autoit]

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Close", $hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    _Pause()
    $bNewGame = False

    [/autoit] [autoit][/autoit] [autoit]

    $nT_CoolDown = TimerInit()
    $nT_DisplayWave = TimerInit()
    $nRestartCheck = 0

    [/autoit] [autoit][/autoit] [autoit]

    $nT_Sleep = TimerInit() + $nSleepTime
    $nT_UpdateFPS = TimerInit()
    $nT_AdjustSleepTime = TimerInit()

    [/autoit] [autoit][/autoit] [autoit]

    While True
    _istPause()
    If $pause == False Then
    DllStructSetData($tPrecSleep, "time", -10000 * ($nSleepTime - TimerDiff($nT_Sleep) + $nOffsetSleepTime))
    DllCall($vNTdll, "dword", "ZwDelayExecution", "int", 0, "ptr", $pPrecSleep)
    $nFrameTime = TimerDiff($nT_Sleep)
    $nT_Sleep = TimerInit()

    [/autoit] [autoit][/autoit] [autoit]

    $nFPS_Cur = 1000 / $nFrameTime
    If TimerDiff($nT_UpdateFPS) >= 500 Then
    $nFPS_Average = ($nFPS_Average * ($iCounter - 1) + $nFPS_Cur) / $iCounter
    $iCounter += 1
    $nFPS_Display = $nFPS_Cur
    $nT_UpdateFPS = TimerInit()
    EndIf
    If TimerDiff($nT_AdjustSleepTime) >= 5000 Then
    If $nFPS_Average - $nFPS < -2 Then $nOffsetSleepTime -= 0.5
    If $nFPS_Average - $nFPS > 2 Then $nOffsetSleepTime += 0.5
    $iCounter = 1
    $nT_AdjustSleepTime = TimerInit()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Switch _IsPressed("20", $vUser32Dll)
    Case True
    Switch $nTimeMod
    Case 1
    If $nSlowMotionFuel >= 10 Then
    $nTimeMod = $nSlowMotion
    $nSlowMotionFuel -= $nSlowMotionConsumptionSpeed / $nFPS_Cur
    EndIf
    Case $nSlowMotion
    If $nSlowMotionFuel > 0 Then
    $nSlowMotionFuel -= $nSlowMotionConsumptionSpeed / $nFPS_Cur
    Else
    $nTimeMod = 1
    EndIf
    EndSwitch
    Case False
    $nTimeMod = 1
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    $nFPS_Cur *= $nTimeMod

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case $nLifeForce >= 1 And $nLifeForce < $nLifeForcePlayer
    $nLifeForce += $nHealthRegenSpeed / $nFPS_Cur
    Case $nLifeForce > $nLifeForcePlayer
    $nLifeForce = $nLifeForcePlayer
    Case $nLifeForce <= 0
    $iWaveCounter = 1
    $bNewWave = True
    $bNewGame = True
    _Pause()
    $bNewGame = False
    _Restart()
    EndSelect

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case $nSlowMotionFuel >= 0 And $nSlowMotionFuel < $nSlowMotionFuelMax
    $nSlowMotionFuel += $nSlowMotionRefillSpeed / $nFPS_Cur
    Case $nSlowMotionFuel > $nSlowMotionFuelMax
    $nSlowMotionFuel = $nSlowMotionFuelMax
    Case $nSlowMotionFuel < 0
    $nSlowMotionFuel = 0
    EndSelect

    [/autoit] [autoit][/autoit] [autoit]

    $aCursorInfo = GUIGetCursorInfo($hWnd)
    If $aCursorInfo[2] And TimerDiff($nT_CoolDown) >= $iCoolDownPlayer * $nTimeMod Then
    $aProjectiles[0][0] += 1
    ReDim $aProjectiles[$aProjectiles[0][0] + 1][6]

    [/autoit] [autoit][/autoit] [autoit]

    $aDiff = _Vector_Create($aCursorInfo[0] - $nX_PlayerPos, $aCursorInfo[1] - $nY_PlayerPos)
    $aDirection = _Vector_Normalize($aDiff)

    [/autoit] [autoit][/autoit] [autoit]

    $aProjectiles[$aProjectiles[0][0]][0] = $nX_PlayerPos
    $aProjectiles[$aProjectiles[0][0]][1] = $nY_PlayerPos
    $aProjectiles[$aProjectiles[0][0]][2] = $aDirection[0] * $nProjectileSpeedPlayer
    $aProjectiles[$aProjectiles[0][0]][3] = $aDirection[1] * $nProjectileSpeedPlayer
    $aProjectiles[$aProjectiles[0][0]][4] = 8
    $aProjectiles[$aProjectiles[0][0]][5] = 1

    [/autoit] [autoit][/autoit] [autoit]

    $nT_CoolDown = TimerInit()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $aAccelForce[0] = 0
    $aAccelForce[1] = 0

    [/autoit] [autoit][/autoit] [autoit]

    If _IsPressed("25", $vUser32Dll) Or _IsPressed("41", $vUser32Dll) And Sqrt($nX_PlayerSpeed ^ 2 + $nY_PlayerSpeed ^ 2) < $nPlayerSpeedMax Then $aAccelForce[0] = -1
    If _IsPressed("26", $vUser32Dll) Or _IsPressed("57", $vUser32Dll) And Sqrt($nX_PlayerSpeed ^ 2 + $nY_PlayerSpeed ^ 2) < $nPlayerSpeedMax Then $aAccelForce[1] = -1
    If _IsPressed("27", $vUser32Dll) Or _IsPressed("44", $vUser32Dll) And Sqrt($nX_PlayerSpeed ^ 2 + $nY_PlayerSpeed ^ 2) < $nPlayerSpeedMax Then $aAccelForce[0] = 1
    If _IsPressed("28", $vUser32Dll) Or _IsPressed("53", $vUser32Dll) And Sqrt($nX_PlayerSpeed ^ 2 + $nY_PlayerSpeed ^ 2) < $nPlayerSpeedMax Then $aAccelForce[1] = 1

    [/autoit] [autoit][/autoit] [autoit]

    $aAccelDirection = _Vector_Normalize($aAccelForce)
    $nX_PlayerSpeed += $aAccelDirection[0] * $nAccelerationForce
    $nY_PlayerSpeed += $aAccelDirection[1] * $nAccelerationForce

    [/autoit] [autoit][/autoit] [autoit]

    $nX_PlayerSpeed *= $nFriction
    $nY_PlayerSpeed *= $nFriction
    $nX_PlayerPos += $nX_PlayerSpeed / $nFPS_Cur
    $nY_PlayerPos += $nY_PlayerSpeed / $nFPS_Cur

    [/autoit] [autoit][/autoit] [autoit]

    If $nX_PlayerPos - 10 <= 0 And $nX_PlayerSpeed < 0 Then
    $nX_PlayerSpeed *= -1
    $nX_PlayerPos = 10
    EndIf
    If $nX_PlayerPos + 10 >= $iGUIWidth And $nX_PlayerSpeed > 0 Then
    $nX_PlayerSpeed *= -1
    $nX_PlayerPos = $iGUIWidth - 10
    EndIf
    If $nY_PlayerPos - 10 <= 0 And $nY_PlayerSpeed < 0 Then
    $nY_PlayerSpeed *= -1
    $nY_PlayerPos = 10
    EndIf
    If $nY_PlayerPos + 10 >= $iGUIHeight And $nY_PlayerSpeed > 0 Then
    $nY_PlayerSpeed *= -1
    $nY_PlayerPos = $iGUIHeight - 10
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
    Switch TimerDiff($nT_DisplayWave) < $nDisplayWave
    Case True
    Switch $bNewWave
    Case True
    $nLifeForce = $nLifeForcePlayer
    Dim $aProjectiles[1][6] = [[0]]
    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "Wave 1", $hFont_Announcement, _GDIPlus_RectFCreate(), $hStringFormat)
    $tLayout_Announcement = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_Announcement, "X", $iGUIWidth / 2 - DllStructGetData($tLayout_Announcement, "Width") / 2)
    DllStructSetData($tLayout_Announcement, "Y", $iGUIHeight / 2 - DllStructGetData($tLayout_Announcement, "Height") / 2)
    DllStructSetData($tLayout_Announcement, "Width", 0)
    DllStructSetData($tLayout_Announcement, "Height", 0)
    $bNewWave = False
    EndSwitch
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Wave " & $iWaveCounter, $hFont_Announcement, $tLayout_Announcement, $hStringFormat, $hBrush_Announcement)
    Case False
    If $nRestartCheck < $nT_DisplayWave Then
    _Restart()
    $nRestartCheck = $nT_DisplayWave
    EndIf
    If $aEnemys[0][0] = 0 Then
    $nT_DisplayWave = TimerInit()
    $bNewWave = True
    $iWaveCounter += 1
    EndIf
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $aEnemys[0][0]
    If $i > $aEnemys[0][0] Then ExitLoop
    If $aEnemys[$i][4] <= 0 Then
    _ArrayDelete($aEnemys, $i)
    $aEnemys[0][0] -= 1
    $i -= 1
    Else
    If TimerDiff($aEnemys[$i][5]) >= $aEnemys[$i][6] * $nTimeMod Then
    $aProjectiles[0][0] += 1
    ReDim $aProjectiles[$aProjectiles[0][0] + 1][6]

    [/autoit] [autoit][/autoit] [autoit]

    $aDiff = _Vector_Create($nX_PlayerPos - $aEnemys[$i][0], $nY_PlayerPos - $aEnemys[$i][1])
    $aDirection = _Vector_Normalize($aDiff)

    [/autoit] [autoit][/autoit] [autoit]

    $aProjectiles[$aProjectiles[0][0]][0] = $aEnemys[$i][0]
    $aProjectiles[$aProjectiles[0][0]][1] = $aEnemys[$i][1]
    $aProjectiles[$aProjectiles[0][0]][2] = $aDirection[0] * $nProjectileSpeedEnemy
    $aProjectiles[$aProjectiles[0][0]][3] = $aDirection[1] * $nProjectileSpeedEnemy
    $aProjectiles[$aProjectiles[0][0]][4] = 5
    $aProjectiles[$aProjectiles[0][0]][5] = 0

    [/autoit] [autoit][/autoit] [autoit]

    $aEnemys[$i][5] = TimerInit()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $aEnemys[$i][0] += $aEnemys[$i][2] / $nFPS_Cur
    $aEnemys[$i][1] += $aEnemys[$i][3] / $nFPS_Cur

    [/autoit] [autoit][/autoit] [autoit]

    If $aEnemys[$i][0] - 10 <= 0 And $aEnemys[$i][2] < 0 Then $aEnemys[$i][2] *= -1
    If $aEnemys[$i][0] + 10 >= $iGUIWidth And $aEnemys[$i][2] > 0 Then $aEnemys[$i][2] *= -1
    If $aEnemys[$i][1] - 10 <= 0 And $aEnemys[$i][3] < 0 Then $aEnemys[$i][3] *= -1
    If $aEnemys[$i][1] + 10 >= $iGUIHeight And $aEnemys[$i][3] > 0 Then $aEnemys[$i][3] *= -1

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsFillEllipse($hGraphic, $aEnemys[$i][0] - 10, $aEnemys[$i][1] - 10, 20, 20, $hBrush_Enemy)
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsFillEllipse($hGraphic, $nX_PlayerPos - 10, $nY_PlayerPos - 10, 20, 20, $hBrush_Player)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $aProjectiles[0][0]
    If $i > $aProjectiles[0][0] Then ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($tPoint, "X", $aProjectiles[$i][0])
    DllStructSetData($tPoint, "Y", $aProjectiles[$i][1])

    [/autoit] [autoit][/autoit] [autoit]

    If _WinAPI_PtInRect($tRectBorder, $tPoint) Then

    [/autoit] [autoit][/autoit] [autoit]

    $aProjectiles[$i][0] += $aProjectiles[$i][2] / $nFPS_Cur
    $aProjectiles[$i][1] += $aProjectiles[$i][3] / $nFPS_Cur

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsFillEllipse($hGraphic, $aProjectiles[$i][0] - 4, $aProjectiles[$i][1] - 4, 8, 8, $hBrush_ProjectileBG)

    [/autoit] [autoit][/autoit] [autoit]

    Switch $aProjectiles[$i][5]
    Case 0
    _GDIPlus_GraphicsFillEllipse($hGraphic, $aProjectiles[$i][0] - 3, $aProjectiles[$i][1] - 3, 6, 6, $hBrush_Enemy)
    Case 1
    _GDIPlus_GraphicsFillEllipse($hGraphic, $aProjectiles[$i][0] - 3, $aProjectiles[$i][1] - 3, 6, 6, $hBrush_Player)
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    Switch $aProjectiles[$i][5]
    Case 0
    If _CircleIsTouchingCircle($aProjectiles[$i][0], $aProjectiles[$i][1], $nX_PlayerPos, $nY_PlayerPos, 6, 10) Then
    $nLifeForce -= $aProjectiles[$i][4]
    _ArrayDelete($aProjectiles, $i)
    $aProjectiles[0][0] -= 1
    $i -= 1
    EndIf
    Case 1
    For $i2 = 1 To $aEnemys[0][0]
    If _CircleIsTouchingCircle($aProjectiles[$i][0], $aProjectiles[$i][1], $aEnemys[$i2][0], $aEnemys[$i2][1], 6, 10) Then
    $aEnemys[$i2][4] -= $aProjectiles[$i][4]
    _ArrayDelete($aProjectiles, $i)
    $aProjectiles[0][0] -= 1
    $i -= 1
    ExitLoop
    EndIf
    Next
    EndSwitch
    Else
    _ArrayDelete($aProjectiles, $i)
    $aProjectiles[0][0] -= 1
    $i -= 1
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawRect($hGraphic, 5, 5, 100, 10, $hPen_Bar)
    _GDIPlus_GraphicsDrawRect($hGraphic, 5, 18, 100, 10, $hPen_Bar)
    _GDIPlus_GraphicsFillRect($hGraphic, 5, 5, $nLifeForce * 100 / $nLifeForcePlayer, 10, $hBrush_LifeBar)
    _GDIPlus_GraphicsFillRect($hGraphic, 5, 18, $nSlowMotionFuel * 100 / $nSlowMotionFuelMax, 10, $hBrush_SlowMotionBar)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawEllipse($hGraphic, $aCursorInfo[0] - 8, $aCursorInfo[1] - 8, 16, 16, $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0], $aCursorInfo[1] - 11, $aCursorInfo[0], $aCursorInfo[1] - 4, $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0] - 11, $aCursorInfo[1], $aCursorInfo[0] - 4, $aCursorInfo[1], $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0], $aCursorInfo[1] + 11, $aCursorInfo[0], $aCursorInfo[1] + 4, $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0] + 11, $aCursorInfo[1], $aCursorInfo[0] + 4, $aCursorInfo[1], $hPen_Cursor)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "FPS " & Int($nFPS_Display), $hFont_FPS, $tLayout_FPS, $hStringFormat, $hBrush_FPS)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_BitBlt($hDC, 0, 0, $iGUIWidth, $iGUIHeight, $hCDC_Buffer, 0, 0, 0x00CC0020)

    [/autoit] [autoit][/autoit] [autoit]

    Switch _IsPressed("50", $vUser32Dll)
    Case True
    Dim $aTimerOffset[4 + $aEnemys[0][0]]

    [/autoit] [autoit][/autoit] [autoit]

    $aTimerOffset[0] = TimerDiff($nT_Sleep)
    $aTimerOffset[1] = TimerDiff($nT_UpdateFPS)
    $aTimerOffset[2] = TimerDiff($nT_AdjustSleepTime)
    $aTimerOffset[3] = TimerDiff($nT_CoolDown)
    For $i = 1 To $aEnemys[0][0]
    $aTimerOffset[$i + 3] = TimerDiff($aEnemys[$i][5])
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _Pause()

    [/autoit] [autoit][/autoit] [autoit]

    $nT_Sleep = TimerInit() - $aTimerOffset[0]
    $nT_UpdateFPS = TimerInit() - $aTimerOffset[1]
    $nT_AdjustSleepTime = TimerInit() - $aTimerOffset[2]
    $nT_CoolDown = TimerInit() - $aTimerOffset[3]
    For $i = 1 To $aEnemys[0][0]
    $aEnemys[$i][5] = TimerInit() - $aTimerOffset[$i + 3]
    Next
    EndSwitch
    Else
    Sleep(10)
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Pause()
    $hBitmapBG = _GDIPlus_BitmapCreateFromHBITMAP($hGDI_Bitmap)
    $hGraphicTmp = _GDIPlus_ImageGetGraphicsContext($hBitmapBG)
    _GDIPlus_GraphicsFillRect($hGraphicTmp, 0, 0, $iGUIWidth, $iGUIHeight, $hBrush_BG_Menu)
    _GDIPlus_GraphicsDispose($hGraphicTmp)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Sleep(20)
    Until Not _IsPressed("50", $vUser32Dll)

    [/autoit] [autoit][/autoit] [autoit]

    $nT_Sleep = TimerInit() + $nSleepTime
    $nT_UpdateFPS = TimerInit()
    $nT_AdjustSleepTime = TimerInit()

    [/autoit] [autoit][/autoit] [autoit]

    While Not _IsPressed("50", $vUser32Dll)
    DllStructSetData($tPrecSleep, "time", -10000 * ($nSleepTime - TimerDiff($nT_Sleep) + $nOffsetSleepTime))
    DllCall($vNTdll, "dword", "ZwDelayExecution", "int", 0, "ptr", $pPrecSleep)
    $nFrameTime = TimerDiff($nT_Sleep)
    $nT_Sleep = TimerInit()

    [/autoit] [autoit][/autoit] [autoit]

    $nFPS_Cur = 1000 / $nFrameTime
    If TimerDiff($nT_UpdateFPS) >= 500 Then
    $nFPS_Average = ($nFPS_Average * ($iCounter - 1) + $nFPS_Cur) / $iCounter
    $iCounter += 1
    $nFPS_Display = $nFPS_Cur
    $nT_UpdateFPS = TimerInit()
    EndIf
    If TimerDiff($nT_AdjustSleepTime) >= 5000 Then
    If $nFPS_Average - $nFPS < -2 Then $nOffsetSleepTime -= 0.5
    If $nFPS_Average - $nFPS > 2 Then $nOffsetSleepTime += 0.5
    $iCounter = 1
    $nT_AdjustSleepTime = TimerInit()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $aCursorInfo = GUIGetCursorInfo($hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmapBG, 0, 0, $iGUIWidth, $iGUIHeight)
    Switch $bNewGame
    Case True
    Switch _PointIsInRect($aCursorInfo[0], $aCursorInfo[1], DllStructGetData($tLayout_Menu_Start, "X"), DllStructGetData($tLayout_Menu_Start, "Y"), DllStructGetData($tLayout_Menu_Start, "Width"), DllStructGetData($tLayout_Menu_Start, "Height"))
    Case True
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Start", $hFont_Menu, $tLayout_Menu_Start, $hStringFormat, $hBrush_MenuTextHighlight)
    If $aCursorInfo[2] Then ExitLoop
    Case False
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Start", $hFont_Menu, $tLayout_Menu_Start, $hStringFormat, $hBrush_MenuTextNormal)
    EndSwitch
    Case False
    Switch _PointIsInRect($aCursorInfo[0], $aCursorInfo[1], DllStructGetData($tLayout_Menu_Continue, "X"), DllStructGetData($tLayout_Menu_Continue, "Y"), DllStructGetData($tLayout_Menu_Continue, "Width"), DllStructGetData($tLayout_Menu_Continue, "Height"))
    Case True
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Continue", $hFont_Menu, $tLayout_Menu_Continue, $hStringFormat, $hBrush_MenuTextHighlight)
    If $aCursorInfo[2] Then ExitLoop
    Case False
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Continue", $hFont_Menu, $tLayout_Menu_Continue, $hStringFormat, $hBrush_MenuTextNormal)
    EndSwitch
    EndSwitch
    Switch _PointIsInRect($aCursorInfo[0], $aCursorInfo[1], DllStructGetData($tLayout_Menu_Quit, "X"), DllStructGetData($tLayout_Menu_Quit, "Y"), DllStructGetData($tLayout_Menu_Quit, "Width"), DllStructGetData($tLayout_Menu_Quit, "Height"))
    Case True
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Quit", $hFont_Menu, $tLayout_Menu_Quit, $hStringFormat, $hBrush_MenuTextHighlight)
    If $aCursorInfo[2] Then _Close()
    Case False
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Quit", $hFont_Menu, $tLayout_Menu_Quit, $hStringFormat, $hBrush_MenuTextNormal)
    EndSwitch
    _GDIPlus_GraphicsDrawEllipse($hGraphic, $aCursorInfo[0] - 8, $aCursorInfo[1] - 8, 16, 16, $hPen_Cursor)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "FPS " & Int($nFPS_Display), $hFont_FPS, $tLayout_FPS, $hStringFormat, $hBrush_FPS)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0], $aCursorInfo[1] - 11, $aCursorInfo[0], $aCursorInfo[1] - 4, $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0] - 11, $aCursorInfo[1], $aCursorInfo[0] - 4, $aCursorInfo[1], $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0], $aCursorInfo[1] + 11, $aCursorInfo[0], $aCursorInfo[1] + 4, $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0] + 11, $aCursorInfo[1], $aCursorInfo[0] + 4, $aCursorInfo[1], $hPen_Cursor)
    _WinAPI_BitBlt($hDC, 0, 0, $iGUIWidth, $iGUIHeight, $hCDC_Buffer, 0, 0, 0x00CC0020)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    If $bNewGame Then
    $nT_DisplayWave = TimerInit()
    $bNewWave = True
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Sleep(20)
    Until Not _IsPressed("50", $vUser32Dll) And Not _IsPressed("01", $vUser32Dll)
    EndFunc ;==>_Pause

    [/autoit] [autoit][/autoit] [autoit]

    Func _Restart()
    $iEnemys = Ceiling($iWaveCounter / 5)
    If $iEnemys > 8 Then $iEnemys = 8

    [/autoit] [autoit][/autoit] [autoit]

    $nProjectileSpeedEnemy = 200 + $iWaveCounter * 5
    $nEnemySpeed = Random($iWaveCounter * 10 + 50, $iWaveCounter * 10 + 100, 1)
    If $nEnemySpeed > 500 Then $nEnemySpeed = Random(400, 500, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Dim $aEnemys[$iEnemys + 1][7] = [[$iEnemys]]
    For $i = 1 To $aEnemys[0][0]
    $aEnemys[$i][0] = Random(10, $iGUIWidth - 10)
    $aEnemys[$i][1] = Random(10, $iGUIHeight - 10)
    $aNormTmp = _Vector_Normalize(_Vector_Create(Random(-1, 1), Random(-1, 1)))
    $aEnemys[$i][2] = $aNormTmp[0] * $nEnemySpeed
    $aEnemys[$i][3] = $aNormTmp[1] * $nEnemySpeed
    $aEnemys[$i][4] = 5 + $iWaveCounter * 5
    $aEnemys[$i][5] = TimerInit()
    $aEnemys[$i][6] = Random(800 - $iWaveCounter * 5, 1000 - $iWaveCounter * 5, 1)
    If $aEnemys[$i][6] < 200 Then $aEnemys[$i][6] = Random(200, 250, 1)
    Next
    EndFunc ;==>_Restart

    [/autoit] [autoit][/autoit] [autoit]

    Func _Close()
    _WinAPI_ReleaseDC($hWnd, $hDC)
    _WinAPI_DeleteDC($hCDC_Buffer)
    _WinAPI_DeleteObject($hGDI_Bitmap)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_BitmapDispose($hBitmapBG)
    _GDIPlus_BrushDispose($hBrush_Player)
    _GDIPlus_BrushDispose($hBrush_Enemy)
    _GDIPlus_BrushDispose($hBrush_BG_Menu)
    _GDIPlus_BrushDispose($hBrush_FPS)
    _GDIPlus_BrushDispose($hBrush_ProjectileBG)
    _GDIPlus_BrushDispose($hBrush_MenuTextNormal)
    _GDIPlus_BrushDispose($hBrush_MenuTextHighlight)
    _GDIPlus_BrushDispose($hBrush_LifeBar)
    _GDIPlus_BrushDispose($hBrush_SlowMotionBar)
    _GDIPlus_BrushDispose($hBrush_Announcement)
    _GDIPlus_PenDispose($hPen_Bar)
    _GDIPlus_PenDispose($hPen_Cursor)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_FontFamilyDispose($hFamily_SegoeUI)
    _GDIPlus_FontDispose($hFont_FPS)
    _GDIPlus_FontDispose($hFont_Menu)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    DllClose($vUser32Dll)
    DllClose($vNTdll)
    Exit
    EndFunc ;==>_Close

    [/autoit] [autoit][/autoit] [autoit]

    Func _PointIsInCircle($iX_Point, $iY_Point, $iX_Circle, $iY_Circle, $iRadius_Circle)
    $iDistPoints = _GetPointsDistance($iX_Point, $iY_Point, $iX_Circle, $iY_Circle)
    If ($iRadius_Circle > 0 And $iDistPoints < $iRadius_Circle) Or ($iRadius_Circle < 0 And $iDistPoints > $iRadius_Circle) Or $iDistPoints = 0 Then Return 1
    Return 0
    EndFunc ;==>_PointIsInCircle

    [/autoit] [autoit][/autoit] [autoit]

    Func _CircleIsTouchingCircle($iX_Circle1, $iY_Circle1, $iX_Circle2, $iY_Circle2, $iRadius_Circle1, $iRadius_Circle2)
    $iDistCircles = _GetPointsDistance($iX_Circle1, $iY_Circle1, $iX_Circle2, $iY_Circle2)
    If $iDistCircles < $iRadius_Circle1 + $iRadius_Circle2 Then Return True
    Return False
    EndFunc ;==>_CircleIsTouchingCircle

    [/autoit] [autoit][/autoit] [autoit]

    Func _PointIsInRect($iX_Point, $iY_Point, $iX_Rect, $iY_Rect, $iWidth_Rect, $iHeight_Rect)
    If $iX_Point >= $iX_Rect And $iX_Point <= $iX_Rect + $iWidth_Rect And $iY_Point >= $iY_Rect And $iY_Point <= $iY_Rect + $iHeight_Rect Then Return 1
    Return 0
    EndFunc ;==>_PointIsInRect

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetPointsDistance($iPointX1, $iPointY1, $iPointX2, $iPointY2)
    Return Sqrt(($iPointX1 - $iPointX2) ^ 2 + ($iPointY1 - $iPointY2) ^ 2)
    EndFunc ;==>_GetPointsDistance

    [/autoit] [autoit][/autoit] [autoit]

    Func _istPause()
    If Not Winactive("AutoIt Arena Fight v1.0 - Author: name22(http://www.autoit.de)") Then
    $pause = True
    Else
    $pause = False
    EndIf
    EndFunc

    [/autoit]
  • DFPWare Das war wohl auch eher ein Beispiel...
    So ich habe jetzt die Spielunterbrechung bei Fokusverlust eingefügt.

    Edit: Jetzt kann man auch nicht mehr durch drücken der Taste P das Pausieren bei Fokusverlust kurzzeitig umgehen. Danke an BadBunny für den hinweis ;).

  • Ich habe es mal "Idiotensicher" gemacht und jetzt eine Font-Abfrage reingebaut, ich mach sie demnächst mal "speziefischer" ...

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>
    #include <GDIPlus.au3>
    #include "VectorMath.au3"
    #include <Misc.au3>
    #include <WinAPI.au3>
    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ; - Author: name22(http://www.autoit.de)

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)
    If IniRead(@ScriptDir & "\font.ini", "Font", "Font", "NO") = "NO" Then
    Global $SelectFont = InputBox("Font", "Type in which font you would" & @CRLF & "use in this game.")
    IniWrite(@ScriptDir & "\font.ini", "Font", "Font", $SelectFont)
    ElseIf IniRead(@ScriptDir & "\font.ini", "Font", "Font", "NO") <> "NO" Then
    $SelectFont = IniRead(@ScriptDir & "\font.ini", "Font", "Font", "NO")
    EndIf
    $iGUIWidth = 600
    $iGUIHeight = 400
    $nFPS = 50

    [/autoit] [autoit][/autoit] [autoit]

    $nSlowMotion = 5

    [/autoit] [autoit][/autoit] [autoit]

    $nFriction = 0.98

    [/autoit] [autoit][/autoit] [autoit]

    $nPlayerSpeedMax = 200
    $nAccelerationForce = 10

    [/autoit] [autoit][/autoit] [autoit]

    $nProjectileSpeedPlayer = 500
    $iCoolDownPlayer = 200

    [/autoit] [autoit][/autoit] [autoit]

    $nSlowMotionFuelMax = 100
    $nSlowMotionFuel = 100
    $nSlowMotionRefillSpeed = 8
    $nSlowMotionConsumptionSpeed = 20

    [/autoit] [autoit][/autoit] [autoit]

    $nLifeForcePlayer = 60
    $nHealthRegenSpeed = 1

    [/autoit] [autoit][/autoit] [autoit]

    $nDisplayWave = 3000

    [/autoit] [autoit][/autoit] [autoit]

    $nSleepTime = 1000 / $nFPS
    $nOffsetSleepTime = 0

    [/autoit] [autoit][/autoit] [autoit]

    $nFPS_Display = 0
    $nFPS_Average = 0
    $iCounter = 1
    $iWaveCounter = 1

    [/autoit] [autoit][/autoit] [autoit]

    $bNewGame = True
    $bNewWave = True

    [/autoit] [autoit][/autoit] [autoit]

    Global $hBitmapBG
    Global $pause = False

    [/autoit] [autoit][/autoit] [autoit]

    $nTimeMod = 1

    [/autoit] [autoit][/autoit] [autoit]

    $vUser32Dll = DllOpen("User32.dll")
    $vNTdll = DllOpen("ntdll.dll")

    [/autoit] [autoit][/autoit] [autoit]

    $tRectBorder = DllStructCreate($tagRECT)
    $tPoint = DllStructCreate($tagPOINT)
    DllStructSetData($tRectBorder, "Left", 0)
    DllStructSetData($tRectBorder, "Top", 0)
    DllStructSetData($tRectBorder, "Right", $iGUIWidth)
    DllStructSetData($tRectBorder, "Bottom", $iGUIHeight)

    [/autoit] [autoit][/autoit] [autoit]

    $tPrecSleep = DllStructCreate("int64 time;")
    $pPrecSleep = DllStructGetPtr($tPrecSleep)

    [/autoit] [autoit][/autoit] [autoit]

    $hWnd = GUICreate("AutoIt Arena Fight v1.0 - Author: name22(http://www.autoit.de)", $iGUIWidth, $iGUIHeight)
    GUISetCursor(16, 1, $hWnd)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    $hDC = _WinAPI_GetDC($hWnd)
    $hCDC_Buffer = _WinAPI_CreateCompatibleDC($hDC)
    $hGDI_Bitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iGUIWidth, $iGUIHeight)
    _WinAPI_SelectObject($hCDC_Buffer, $hGDI_Bitmap)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hCDC_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_BitBlt($hDC, 0, 0, $iGUIWidth, $iGUIHeight, $hCDC_Buffer, 0, 0, 0x00CC0020)

    [/autoit] [autoit][/autoit] [autoit]

    $hBrush_Enemy = _GDIPlus_BrushCreateSolid(0xFFFF0000)
    $hBrush_Player = _GDIPlus_BrushCreateSolid(0xFF0000FF)
    $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xFF000000)
    $hBrush_BG_Menu = _GDIPlus_BrushCreateSolid("0x" & Hex(200, 2) & "F0F0F0")
    $hBrush_ProjectileBG = _GDIPlus_BrushCreateSolid(0xFF000000)
    $hBrush_MenuTextNormal = _GDIPlus_BrushCreateSolid(0xFF000000)
    $hBrush_MenuTextHighlight = _GDIPlus_BrushCreateSolid(0xFF808080)
    $hBrush_LifeBar = _GDIPlus_BrushCreateSolid(0xFFFF0000)
    $hBrush_SlowMotionBar = _GDIPlus_BrushCreateSolid(0xFF0000FF)
    $hBrush_Announcement = _GDIPlus_BrushCreateSolid("0x" & Hex(200, 2) & "000000")

    [/autoit] [autoit][/autoit] [autoit]

    $hPen_Bar = _GDIPlus_PenCreate(0xFF000000, 2)
    $hPen_Cursor = _GDIPlus_PenCreate(0xFF505050, 2)

    [/autoit] [autoit][/autoit] [autoit]

    $hStringFormat = _GDIPlus_StringFormatCreate()
    $hFamily_SegoeUI = _GDIPlus_FontFamilyCreate($SelectFont)
    $hFont_FPS = _GDIPlus_FontCreate($hFamily_SegoeUI, 7)
    $hFont_Menu = _GDIPlus_FontCreate($hFamily_SegoeUI, 20)
    $hFont_Announcement = _GDIPlus_FontCreate($hFamily_SegoeUI, 50)

    [/autoit] [autoit][/autoit] [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "FPS 000", $hFont_FPS, _GDIPlus_RectFCreate(), $hStringFormat)
    $tLayout_FPS = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_FPS, "X", $iGUIWidth - DllStructGetData($tLayout_FPS, "Width") - 3)
    DllStructSetData($tLayout_FPS, "Y", $iGUIHeight - DllStructGetData($tLayout_FPS, "Height"))
    DllStructSetData($tLayout_FPS, "Width", DllStructGetData($tLayout_FPS, "Width") + 3)

    [/autoit] [autoit][/autoit] [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "Continue", $hFont_Menu, _GDIPlus_RectFCreate(0, 100), $hStringFormat)
    $tLayout_Menu_Continue = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_Menu_Continue, "X", $iGUIWidth / 2 - DllStructGetData($tLayout_Menu_Continue, "Width") / 2)
    DllStructSetData($tLayout_Menu_Continue, "Width", DllStructGetData($tLayout_Menu_Continue, "Width") + 1)

    [/autoit] [autoit][/autoit] [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "Start", $hFont_Menu, _GDIPlus_RectFCreate(0, 100), $hStringFormat)
    $tLayout_Menu_Start = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_Menu_Start, "X", $iGUIWidth / 2 - DllStructGetData($tLayout_Menu_Start, "Width") / 2)
    DllStructSetData($tLayout_Menu_Start, "Width", DllStructGetData($tLayout_Menu_Start, "Width") + 1)

    [/autoit] [autoit][/autoit] [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "Quit", $hFont_Menu, _GDIPlus_RectFCreate(0, 150), $hStringFormat)
    $tLayout_Menu_Quit = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_Menu_Quit, "X", $iGUIWidth / 2 - DllStructGetData($tLayout_Menu_Quit, "Width") / 2)
    DllStructSetData($tLayout_Menu_Quit, "Width", DllStructGetData($tLayout_Menu_Quit, "Width") + 1)

    [/autoit] [autoit][/autoit] [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "Wave 1", $hFont_Announcement, _GDIPlus_RectFCreate(), $hStringFormat)
    $tLayout_Announcement = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_Announcement, "X", $iGUIWidth / 2 - DllStructGetData($tLayout_Announcement, "Width") / 2)
    DllStructSetData($tLayout_Announcement, "Y", $iGUIHeight / 2 - DllStructGetData($tLayout_Announcement, "Height") / 2)
    DllStructSetData($tLayout_Announcement, "Width", 0)
    DllStructSetData($tLayout_Announcement, "Height", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $nX_PlayerPos = Random(10, $iGUIWidth - 10)
    $nY_PlayerPos = Random(10, $iGUIHeight - 10)
    $nX_PlayerSpeed = 0
    $nY_PlayerSpeed = 0
    $nLifeForce = $nLifeForcePlayer

    [/autoit] [autoit][/autoit] [autoit]

    Global $aEnemys[1][6] = [[0]], $aProjectiles[1][6] = [[0]], $aAccelForce = _Vector_Create(0, 0), $nProjectileSpeedEnemy

    [/autoit] [autoit][/autoit] [autoit]

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Close", $hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    _Pause()
    $bNewGame = False

    [/autoit] [autoit][/autoit] [autoit]

    $nT_CoolDown = TimerInit()
    $nT_DisplayWave = TimerInit()
    $nRestartCheck = 0

    [/autoit] [autoit][/autoit] [autoit]

    $nT_Sleep = TimerInit() + $nSleepTime
    $nT_UpdateFPS = TimerInit()
    $nT_AdjustSleepTime = TimerInit()

    [/autoit] [autoit][/autoit] [autoit]

    While True
    _istPause()
    If $pause == False Then
    DllStructSetData($tPrecSleep, "time", -10000 * ($nSleepTime - TimerDiff($nT_Sleep) + $nOffsetSleepTime))
    DllCall($vNTdll, "dword", "ZwDelayExecution", "int", 0, "ptr", $pPrecSleep)
    $nFrameTime = TimerDiff($nT_Sleep)
    $nT_Sleep = TimerInit()

    [/autoit] [autoit][/autoit] [autoit]

    $nFPS_Cur = 1000 / $nFrameTime
    If TimerDiff($nT_UpdateFPS) >= 500 Then
    $nFPS_Average = ($nFPS_Average * ($iCounter - 1) + $nFPS_Cur) / $iCounter
    $iCounter += 1
    $nFPS_Display = $nFPS_Cur
    $nT_UpdateFPS = TimerInit()
    EndIf
    If TimerDiff($nT_AdjustSleepTime) >= 5000 Then
    If $nFPS_Average - $nFPS < -2 Then $nOffsetSleepTime -= 0.5
    If $nFPS_Average - $nFPS > 2 Then $nOffsetSleepTime += 0.5
    $iCounter = 1
    $nT_AdjustSleepTime = TimerInit()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Switch _IsPressed("20", $vUser32Dll)
    Case True
    Switch $nTimeMod
    Case 1
    If $nSlowMotionFuel >= 10 Then
    $nTimeMod = $nSlowMotion
    $nSlowMotionFuel -= $nSlowMotionConsumptionSpeed / $nFPS_Cur
    EndIf
    Case $nSlowMotion
    If $nSlowMotionFuel > 0 Then
    $nSlowMotionFuel -= $nSlowMotionConsumptionSpeed / $nFPS_Cur
    Else
    $nTimeMod = 1
    EndIf
    EndSwitch
    Case False
    $nTimeMod = 1
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    $nFPS_Cur *= $nTimeMod

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case $nLifeForce >= 1 And $nLifeForce < $nLifeForcePlayer
    $nLifeForce += $nHealthRegenSpeed / $nFPS_Cur
    Case $nLifeForce > $nLifeForcePlayer
    $nLifeForce = $nLifeForcePlayer
    Case $nLifeForce <= 0
    $iWaveCounter = 1
    $bNewWave = True
    $bNewGame = True
    _Pause()
    $bNewGame = False
    _Restart()
    EndSelect

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case $nSlowMotionFuel >= 0 And $nSlowMotionFuel < $nSlowMotionFuelMax
    $nSlowMotionFuel += $nSlowMotionRefillSpeed / $nFPS_Cur
    Case $nSlowMotionFuel > $nSlowMotionFuelMax
    $nSlowMotionFuel = $nSlowMotionFuelMax
    Case $nSlowMotionFuel < 0
    $nSlowMotionFuel = 0
    EndSelect

    [/autoit] [autoit][/autoit] [autoit]

    $aCursorInfo = GUIGetCursorInfo($hWnd)
    If $aCursorInfo[2] And TimerDiff($nT_CoolDown) >= $iCoolDownPlayer * $nTimeMod Then
    $aProjectiles[0][0] += 1
    ReDim $aProjectiles[$aProjectiles[0][0] + 1][6]

    [/autoit] [autoit][/autoit] [autoit]

    $aDiff = _Vector_Create($aCursorInfo[0] - $nX_PlayerPos, $aCursorInfo[1] - $nY_PlayerPos)
    $aDirection = _Vector_Normalize($aDiff)

    [/autoit] [autoit][/autoit] [autoit]

    $aProjectiles[$aProjectiles[0][0]][0] = $nX_PlayerPos
    $aProjectiles[$aProjectiles[0][0]][1] = $nY_PlayerPos
    $aProjectiles[$aProjectiles[0][0]][2] = $aDirection[0] * $nProjectileSpeedPlayer
    $aProjectiles[$aProjectiles[0][0]][3] = $aDirection[1] * $nProjectileSpeedPlayer
    $aProjectiles[$aProjectiles[0][0]][4] = 8
    $aProjectiles[$aProjectiles[0][0]][5] = 1

    [/autoit] [autoit][/autoit] [autoit]

    $nT_CoolDown = TimerInit()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $aAccelForce[0] = 0
    $aAccelForce[1] = 0

    [/autoit] [autoit][/autoit] [autoit]

    If _IsPressed("25", $vUser32Dll) Or _IsPressed("41", $vUser32Dll) And Sqrt($nX_PlayerSpeed ^ 2 + $nY_PlayerSpeed ^ 2) < $nPlayerSpeedMax Then $aAccelForce[0] = -1
    If _IsPressed("26", $vUser32Dll) Or _IsPressed("57", $vUser32Dll) And Sqrt($nX_PlayerSpeed ^ 2 + $nY_PlayerSpeed ^ 2) < $nPlayerSpeedMax Then $aAccelForce[1] = -1
    If _IsPressed("27", $vUser32Dll) Or _IsPressed("44", $vUser32Dll) And Sqrt($nX_PlayerSpeed ^ 2 + $nY_PlayerSpeed ^ 2) < $nPlayerSpeedMax Then $aAccelForce[0] = 1
    If _IsPressed("28", $vUser32Dll) Or _IsPressed("53", $vUser32Dll) And Sqrt($nX_PlayerSpeed ^ 2 + $nY_PlayerSpeed ^ 2) < $nPlayerSpeedMax Then $aAccelForce[1] = 1

    [/autoit] [autoit][/autoit] [autoit]

    $aAccelDirection = _Vector_Normalize($aAccelForce)
    $nX_PlayerSpeed += $aAccelDirection[0] * $nAccelerationForce
    $nY_PlayerSpeed += $aAccelDirection[1] * $nAccelerationForce

    [/autoit] [autoit][/autoit] [autoit]

    $nX_PlayerSpeed *= $nFriction
    $nY_PlayerSpeed *= $nFriction
    $nX_PlayerPos += $nX_PlayerSpeed / $nFPS_Cur
    $nY_PlayerPos += $nY_PlayerSpeed / $nFPS_Cur

    [/autoit] [autoit][/autoit] [autoit]

    If $nX_PlayerPos - 10 <= 0 And $nX_PlayerSpeed < 0 Then
    $nX_PlayerSpeed *= -1
    $nX_PlayerPos = 10
    EndIf
    If $nX_PlayerPos + 10 >= $iGUIWidth And $nX_PlayerSpeed > 0 Then
    $nX_PlayerSpeed *= -1
    $nX_PlayerPos = $iGUIWidth - 10
    EndIf
    If $nY_PlayerPos - 10 <= 0 And $nY_PlayerSpeed < 0 Then
    $nY_PlayerSpeed *= -1
    $nY_PlayerPos = 10
    EndIf
    If $nY_PlayerPos + 10 >= $iGUIHeight And $nY_PlayerSpeed > 0 Then
    $nY_PlayerSpeed *= -1
    $nY_PlayerPos = $iGUIHeight - 10
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
    Switch TimerDiff($nT_DisplayWave) < $nDisplayWave
    Case True
    Switch $bNewWave
    Case True
    $nLifeForce = $nLifeForcePlayer
    Dim $aProjectiles[1][6] = [[0]]
    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "Wave 1", $hFont_Announcement, _GDIPlus_RectFCreate(), $hStringFormat)
    $tLayout_Announcement = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_Announcement, "X", $iGUIWidth / 2 - DllStructGetData($tLayout_Announcement, "Width") / 2)
    DllStructSetData($tLayout_Announcement, "Y", $iGUIHeight / 2 - DllStructGetData($tLayout_Announcement, "Height") / 2)
    DllStructSetData($tLayout_Announcement, "Width", 0)
    DllStructSetData($tLayout_Announcement, "Height", 0)
    $bNewWave = False
    EndSwitch
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Wave " & $iWaveCounter, $hFont_Announcement, $tLayout_Announcement, $hStringFormat, $hBrush_Announcement)
    Case False
    If $nRestartCheck < $nT_DisplayWave Then
    _Restart()
    $nRestartCheck = $nT_DisplayWave
    EndIf
    If $aEnemys[0][0] = 0 Then
    $nT_DisplayWave = TimerInit()
    $bNewWave = True
    $iWaveCounter += 1
    EndIf
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $aEnemys[0][0]
    If $i > $aEnemys[0][0] Then ExitLoop
    If $aEnemys[$i][4] <= 0 Then
    _ArrayDelete($aEnemys, $i)
    $aEnemys[0][0] -= 1
    $i -= 1
    Else
    If TimerDiff($aEnemys[$i][5]) >= $aEnemys[$i][6] * $nTimeMod Then
    $aProjectiles[0][0] += 1
    ReDim $aProjectiles[$aProjectiles[0][0] + 1][6]

    [/autoit] [autoit][/autoit] [autoit]

    $aDiff = _Vector_Create($nX_PlayerPos - $aEnemys[$i][0], $nY_PlayerPos - $aEnemys[$i][1])
    $aDirection = _Vector_Normalize($aDiff)

    [/autoit] [autoit][/autoit] [autoit]

    $aProjectiles[$aProjectiles[0][0]][0] = $aEnemys[$i][0]
    $aProjectiles[$aProjectiles[0][0]][1] = $aEnemys[$i][1]
    $aProjectiles[$aProjectiles[0][0]][2] = $aDirection[0] * $nProjectileSpeedEnemy
    $aProjectiles[$aProjectiles[0][0]][3] = $aDirection[1] * $nProjectileSpeedEnemy
    $aProjectiles[$aProjectiles[0][0]][4] = 5
    $aProjectiles[$aProjectiles[0][0]][5] = 0

    [/autoit] [autoit][/autoit] [autoit]

    $aEnemys[$i][5] = TimerInit()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $aEnemys[$i][0] += $aEnemys[$i][2] / $nFPS_Cur
    $aEnemys[$i][1] += $aEnemys[$i][3] / $nFPS_Cur

    [/autoit] [autoit][/autoit] [autoit]

    If $aEnemys[$i][0] - 10 <= 0 And $aEnemys[$i][2] < 0 Then $aEnemys[$i][2] *= -1
    If $aEnemys[$i][0] + 10 >= $iGUIWidth And $aEnemys[$i][2] > 0 Then $aEnemys[$i][2] *= -1
    If $aEnemys[$i][1] - 10 <= 0 And $aEnemys[$i][3] < 0 Then $aEnemys[$i][3] *= -1
    If $aEnemys[$i][1] + 10 >= $iGUIHeight And $aEnemys[$i][3] > 0 Then $aEnemys[$i][3] *= -1

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsFillEllipse($hGraphic, $aEnemys[$i][0] - 10, $aEnemys[$i][1] - 10, 20, 20, $hBrush_Enemy)
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsFillEllipse($hGraphic, $nX_PlayerPos - 10, $nY_PlayerPos - 10, 20, 20, $hBrush_Player)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $aProjectiles[0][0]
    If $i > $aProjectiles[0][0] Then ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($tPoint, "X", $aProjectiles[$i][0])
    DllStructSetData($tPoint, "Y", $aProjectiles[$i][1])

    [/autoit] [autoit][/autoit] [autoit]

    If _WinAPI_PtInRect($tRectBorder, $tPoint) Then

    [/autoit] [autoit][/autoit] [autoit]

    $aProjectiles[$i][0] += $aProjectiles[$i][2] / $nFPS_Cur
    $aProjectiles[$i][1] += $aProjectiles[$i][3] / $nFPS_Cur

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsFillEllipse($hGraphic, $aProjectiles[$i][0] - 4, $aProjectiles[$i][1] - 4, 8, 8, $hBrush_ProjectileBG)

    [/autoit] [autoit][/autoit] [autoit]

    Switch $aProjectiles[$i][5]
    Case 0
    _GDIPlus_GraphicsFillEllipse($hGraphic, $aProjectiles[$i][0] - 3, $aProjectiles[$i][1] - 3, 6, 6, $hBrush_Enemy)
    Case 1
    _GDIPlus_GraphicsFillEllipse($hGraphic, $aProjectiles[$i][0] - 3, $aProjectiles[$i][1] - 3, 6, 6, $hBrush_Player)
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    Switch $aProjectiles[$i][5]
    Case 0
    If _CircleIsTouchingCircle($aProjectiles[$i][0], $aProjectiles[$i][1], $nX_PlayerPos, $nY_PlayerPos, 6, 10) Then
    $nLifeForce -= $aProjectiles[$i][4]
    _ArrayDelete($aProjectiles, $i)
    $aProjectiles[0][0] -= 1
    $i -= 1
    EndIf
    Case 1
    For $i2 = 1 To $aEnemys[0][0]
    If _CircleIsTouchingCircle($aProjectiles[$i][0], $aProjectiles[$i][1], $aEnemys[$i2][0], $aEnemys[$i2][1], 6, 10) Then
    $aEnemys[$i2][4] -= $aProjectiles[$i][4]
    _ArrayDelete($aProjectiles, $i)
    $aProjectiles[0][0] -= 1
    $i -= 1
    ExitLoop
    EndIf
    Next
    EndSwitch
    Else
    _ArrayDelete($aProjectiles, $i)
    $aProjectiles[0][0] -= 1
    $i -= 1
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawRect($hGraphic, 5, 5, 100, 10, $hPen_Bar)
    _GDIPlus_GraphicsDrawRect($hGraphic, 5, 18, 100, 10, $hPen_Bar)
    _GDIPlus_GraphicsFillRect($hGraphic, 5, 5, $nLifeForce * 100 / $nLifeForcePlayer, 10, $hBrush_LifeBar)
    _GDIPlus_GraphicsFillRect($hGraphic, 5, 18, $nSlowMotionFuel * 100 / $nSlowMotionFuelMax, 10, $hBrush_SlowMotionBar)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawEllipse($hGraphic, $aCursorInfo[0] - 8, $aCursorInfo[1] - 8, 16, 16, $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0], $aCursorInfo[1] - 11, $aCursorInfo[0], $aCursorInfo[1] - 4, $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0] - 11, $aCursorInfo[1], $aCursorInfo[0] - 4, $aCursorInfo[1], $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0], $aCursorInfo[1] + 11, $aCursorInfo[0], $aCursorInfo[1] + 4, $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0] + 11, $aCursorInfo[1], $aCursorInfo[0] + 4, $aCursorInfo[1], $hPen_Cursor)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "FPS " & Int($nFPS_Display), $hFont_FPS, $tLayout_FPS, $hStringFormat, $hBrush_FPS)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_BitBlt($hDC, 0, 0, $iGUIWidth, $iGUIHeight, $hCDC_Buffer, 0, 0, 0x00CC0020)

    [/autoit] [autoit][/autoit] [autoit]

    Switch _IsPressed("50", $vUser32Dll)
    Case True
    Dim $aTimerOffset[4 + $aEnemys[0][0]]

    [/autoit] [autoit][/autoit] [autoit]

    $aTimerOffset[0] = TimerDiff($nT_Sleep)
    $aTimerOffset[1] = TimerDiff($nT_UpdateFPS)
    $aTimerOffset[2] = TimerDiff($nT_AdjustSleepTime)
    $aTimerOffset[3] = TimerDiff($nT_CoolDown)
    For $i = 1 To $aEnemys[0][0]
    $aTimerOffset[$i + 3] = TimerDiff($aEnemys[$i][5])
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _Pause()

    [/autoit] [autoit][/autoit] [autoit]

    $nT_Sleep = TimerInit() - $aTimerOffset[0]
    $nT_UpdateFPS = TimerInit() - $aTimerOffset[1]
    $nT_AdjustSleepTime = TimerInit() - $aTimerOffset[2]
    $nT_CoolDown = TimerInit() - $aTimerOffset[3]
    For $i = 1 To $aEnemys[0][0]
    $aEnemys[$i][5] = TimerInit() - $aTimerOffset[$i + 3]
    Next
    EndSwitch
    Else
    Sleep(10)
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Pause()
    $hBitmapBG = _GDIPlus_BitmapCreateFromHBITMAP($hGDI_Bitmap)
    $hGraphicTmp = _GDIPlus_ImageGetGraphicsContext($hBitmapBG)
    _GDIPlus_GraphicsFillRect($hGraphicTmp, 0, 0, $iGUIWidth, $iGUIHeight, $hBrush_BG_Menu)
    _GDIPlus_GraphicsDispose($hGraphicTmp)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Sleep(20)
    Until Not _IsPressed("50", $vUser32Dll)

    [/autoit] [autoit][/autoit] [autoit]

    $nT_Sleep = TimerInit() + $nSleepTime
    $nT_UpdateFPS = TimerInit()
    $nT_AdjustSleepTime = TimerInit()

    [/autoit] [autoit][/autoit] [autoit]

    While Not _IsPressed("50", $vUser32Dll)
    DllStructSetData($tPrecSleep, "time", -10000 * ($nSleepTime - TimerDiff($nT_Sleep) + $nOffsetSleepTime))
    DllCall($vNTdll, "dword", "ZwDelayExecution", "int", 0, "ptr", $pPrecSleep)
    $nFrameTime = TimerDiff($nT_Sleep)
    $nT_Sleep = TimerInit()

    [/autoit] [autoit][/autoit] [autoit]

    $nFPS_Cur = 1000 / $nFrameTime
    If TimerDiff($nT_UpdateFPS) >= 500 Then
    $nFPS_Average = ($nFPS_Average * ($iCounter - 1) + $nFPS_Cur) / $iCounter
    $iCounter += 1
    $nFPS_Display = $nFPS_Cur
    $nT_UpdateFPS = TimerInit()
    EndIf
    If TimerDiff($nT_AdjustSleepTime) >= 5000 Then
    If $nFPS_Average - $nFPS < -2 Then $nOffsetSleepTime -= 0.5
    If $nFPS_Average - $nFPS > 2 Then $nOffsetSleepTime += 0.5
    $iCounter = 1
    $nT_AdjustSleepTime = TimerInit()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $aCursorInfo = GUIGetCursorInfo($hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmapBG, 0, 0, $iGUIWidth, $iGUIHeight)
    Switch $bNewGame
    Case True
    Switch _PointIsInRect($aCursorInfo[0], $aCursorInfo[1], DllStructGetData($tLayout_Menu_Start, "X"), DllStructGetData($tLayout_Menu_Start, "Y"), DllStructGetData($tLayout_Menu_Start, "Width"), DllStructGetData($tLayout_Menu_Start, "Height"))
    Case True
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Start", $hFont_Menu, $tLayout_Menu_Start, $hStringFormat, $hBrush_MenuTextHighlight)
    If $aCursorInfo[2] Then ExitLoop
    Case False
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Start", $hFont_Menu, $tLayout_Menu_Start, $hStringFormat, $hBrush_MenuTextNormal)
    EndSwitch
    Case False
    Switch _PointIsInRect($aCursorInfo[0], $aCursorInfo[1], DllStructGetData($tLayout_Menu_Continue, "X"), DllStructGetData($tLayout_Menu_Continue, "Y"), DllStructGetData($tLayout_Menu_Continue, "Width"), DllStructGetData($tLayout_Menu_Continue, "Height"))
    Case True
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Continue", $hFont_Menu, $tLayout_Menu_Continue, $hStringFormat, $hBrush_MenuTextHighlight)
    If $aCursorInfo[2] Then ExitLoop
    Case False
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Continue", $hFont_Menu, $tLayout_Menu_Continue, $hStringFormat, $hBrush_MenuTextNormal)
    EndSwitch
    EndSwitch
    Switch _PointIsInRect($aCursorInfo[0], $aCursorInfo[1], DllStructGetData($tLayout_Menu_Quit, "X"), DllStructGetData($tLayout_Menu_Quit, "Y"), DllStructGetData($tLayout_Menu_Quit, "Width"), DllStructGetData($tLayout_Menu_Quit, "Height"))
    Case True
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Quit", $hFont_Menu, $tLayout_Menu_Quit, $hStringFormat, $hBrush_MenuTextHighlight)
    If $aCursorInfo[2] Then _Close()
    Case False
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Quit", $hFont_Menu, $tLayout_Menu_Quit, $hStringFormat, $hBrush_MenuTextNormal)
    EndSwitch
    _GDIPlus_GraphicsDrawEllipse($hGraphic, $aCursorInfo[0] - 8, $aCursorInfo[1] - 8, 16, 16, $hPen_Cursor)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "FPS " & Int($nFPS_Display), $hFont_FPS, $tLayout_FPS, $hStringFormat, $hBrush_FPS)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0], $aCursorInfo[1] - 11, $aCursorInfo[0], $aCursorInfo[1] - 4, $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0] - 11, $aCursorInfo[1], $aCursorInfo[0] - 4, $aCursorInfo[1], $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0], $aCursorInfo[1] + 11, $aCursorInfo[0], $aCursorInfo[1] + 4, $hPen_Cursor)
    _GDIPlus_GraphicsDrawLine($hGraphic, $aCursorInfo[0] + 11, $aCursorInfo[1], $aCursorInfo[0] + 4, $aCursorInfo[1], $hPen_Cursor)
    _WinAPI_BitBlt($hDC, 0, 0, $iGUIWidth, $iGUIHeight, $hCDC_Buffer, 0, 0, 0x00CC0020)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    If $bNewGame Then
    $nT_DisplayWave = TimerInit()
    $bNewWave = True
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Sleep(20)
    Until Not _IsPressed("50", $vUser32Dll) And Not _IsPressed("01", $vUser32Dll)
    EndFunc ;==>_Pause

    [/autoit] [autoit][/autoit] [autoit]

    Func _Restart()
    $iEnemys = Ceiling($iWaveCounter / 5)
    If $iEnemys > 8 Then $iEnemys = 8

    [/autoit] [autoit][/autoit] [autoit]

    $nProjectileSpeedEnemy = 200 + $iWaveCounter * 5
    $nEnemySpeed = Random($iWaveCounter * 10 + 50, $iWaveCounter * 10 + 100, 1)
    If $nEnemySpeed > 500 Then $nEnemySpeed = Random(400, 500, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Dim $aEnemys[$iEnemys + 1][7] = [[$iEnemys]]
    For $i = 1 To $aEnemys[0][0]
    $aEnemys[$i][0] = Random(10, $iGUIWidth - 10)
    $aEnemys[$i][1] = Random(10, $iGUIHeight - 10)
    $aNormTmp = _Vector_Normalize(_Vector_Create(Random(-1, 1), Random(-1, 1)))
    $aEnemys[$i][2] = $aNormTmp[0] * $nEnemySpeed
    $aEnemys[$i][3] = $aNormTmp[1] * $nEnemySpeed
    $aEnemys[$i][4] = 5 + $iWaveCounter * 5
    $aEnemys[$i][5] = TimerInit()
    $aEnemys[$i][6] = Random(800 - $iWaveCounter * 5, 1000 - $iWaveCounter * 5, 1)
    If $aEnemys[$i][6] < 200 Then $aEnemys[$i][6] = Random(200, 250, 1)
    Next
    EndFunc ;==>_Restart

    [/autoit] [autoit][/autoit] [autoit]

    Func _Close()
    _WinAPI_ReleaseDC($hWnd, $hDC)
    _WinAPI_DeleteDC($hCDC_Buffer)
    _WinAPI_DeleteObject($hGDI_Bitmap)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_BitmapDispose($hBitmapBG)
    _GDIPlus_BrushDispose($hBrush_Player)
    _GDIPlus_BrushDispose($hBrush_Enemy)
    _GDIPlus_BrushDispose($hBrush_BG_Menu)
    _GDIPlus_BrushDispose($hBrush_FPS)
    _GDIPlus_BrushDispose($hBrush_ProjectileBG)
    _GDIPlus_BrushDispose($hBrush_MenuTextNormal)
    _GDIPlus_BrushDispose($hBrush_MenuTextHighlight)
    _GDIPlus_BrushDispose($hBrush_LifeBar)
    _GDIPlus_BrushDispose($hBrush_SlowMotionBar)
    _GDIPlus_BrushDispose($hBrush_Announcement)
    _GDIPlus_PenDispose($hPen_Bar)
    _GDIPlus_PenDispose($hPen_Cursor)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_FontFamilyDispose($hFamily_SegoeUI)
    _GDIPlus_FontDispose($hFont_FPS)
    _GDIPlus_FontDispose($hFont_Menu)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    DllClose($vUser32Dll)
    DllClose($vNTdll)
    Exit
    EndFunc ;==>_Close

    [/autoit] [autoit][/autoit] [autoit]

    Func _PointIsInCircle($iX_Point, $iY_Point, $iX_Circle, $iY_Circle, $iRadius_Circle)
    $iDistPoints = _GetPointsDistance($iX_Point, $iY_Point, $iX_Circle, $iY_Circle)
    If ($iRadius_Circle > 0 And $iDistPoints < $iRadius_Circle) Or ($iRadius_Circle < 0 And $iDistPoints > $iRadius_Circle) Or $iDistPoints = 0 Then Return 1
    Return 0
    EndFunc ;==>_PointIsInCircle

    [/autoit] [autoit][/autoit] [autoit]

    Func _CircleIsTouchingCircle($iX_Circle1, $iY_Circle1, $iX_Circle2, $iY_Circle2, $iRadius_Circle1, $iRadius_Circle2)
    $iDistCircles = _GetPointsDistance($iX_Circle1, $iY_Circle1, $iX_Circle2, $iY_Circle2)
    If $iDistCircles < $iRadius_Circle1 + $iRadius_Circle2 Then Return True
    Return False
    EndFunc ;==>_CircleIsTouchingCircle

    [/autoit] [autoit][/autoit] [autoit]

    Func _PointIsInRect($iX_Point, $iY_Point, $iX_Rect, $iY_Rect, $iWidth_Rect, $iHeight_Rect)
    If $iX_Point >= $iX_Rect And $iX_Point <= $iX_Rect + $iWidth_Rect And $iY_Point >= $iY_Rect And $iY_Point <= $iY_Rect + $iHeight_Rect Then Return 1
    Return 0
    EndFunc ;==>_PointIsInRect

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetPointsDistance($iPointX1, $iPointY1, $iPointX2, $iPointY2)
    Return Sqrt(($iPointX1 - $iPointX2) ^ 2 + ($iPointY1 - $iPointY2) ^ 2)
    EndFunc ;==>_GetPointsDistance

    [/autoit] [autoit][/autoit] [autoit]

    Func _istPause()
    If Not WinActive("AutoIt Arena Fight v1.0 - Author: name22(http://www.autoit.de)") Then
    $pause = True
    Else
    $pause = False
    EndIf
    EndFunc ;==>_istPause

    [/autoit]

    Es gibt sehr viele Leute, die glauben. Aber aus Aberglauben.
    - Blaise Pascal

  • Sehr gut geworden, gefällt mir! :)

    Ich könnte mir auch vorstellen, dass man da Fähigkeiten für den Spieler einbaut wie z.B. eine Kegelförmige Welle, Zielsuchende "Rakete", Heilung uvm. Die man sich mit Punkten/Level freischalten kann und begrenzt benutzen kann. Oder es kommen kleine Icons durch Spiel die man einsammeln kann, ähnlich wie in vielen kleinen bekannten Spielen.

    Danke
    Flo

  • Ja so stelle ich mir das auch vor, aber im Moment bin ich dabei das Script ein bisschen sauberer umzusetzen (Der alte Quelltext war selbst für mich teilweise unverständlich ;)). Außerdem habe ich gerade auch durch die Schule ein wenig Stress und Diese hat immer noch Vorrang... Ich weiß nicht wann ich mit diesem Projekt fertig werde (Ich habe mir ja auch einiges vorgenommen), aber ich werde definitiv weiter daran arbeiten.

  • Servus,

    eine wirklich gute Idee und Umsetzung :)

    Bezüglich des Genre, so etwas gibt es schon, Stichwort "Counterstrike 2D" ;)

    Evtl. wäre es interessant wenn man die Größe des Spielfeldes ändern könnte.
    Aber ich denke mal du wirst genug Ideen und Optionen im Hinterkopf haben ;)

    PS: Würde meine Hilfe anbieten, hab in GDI+ allerdings bisher nur ein Snake gescriptet (Thread)

    Gruß

    Prajoss

    "Never touch a running System!"

  • Cool, aber ich habe bei mir die fps erhöht. Man kann ja einfach 999999999999999 oder so was eingeben, dann sind es bei mir kurzzeitig 500 fps und im Durchschnitt so 250 fps. So kann man die Maus (also das Fadenkreuz) flüssiger steuern.

  • Zitat

    Cool, aber ich habe bei mir die fps erhöht. Man kann ja einfach 999999999999999 oder so was eingeben, dann sind es bei mir kurzzeitig 500 fps und im Durchschnitt so 250 fps. So kann man die Maus (also das Fadenkreuz) flüssiger steuern.


    Ich weiß, (was glaubst du wozu diese Variable gedacht ist? :rolleyes: ) aber das wirkt sich eben auf die CPU Last aus. ;) Ein wert von 60 bis 80 sollte eigentlich mehr als genug sein... Wenn ich endlich mal damit fertig werde das Script in ein akzeptable Form zu bringen, so dass ich nicht immer fürchten muss das Script zu zerstören, kann ich es noch ein wenig optimieren. Die Kollisionserkennung ist bis jetzt eher provisorisch und rechenintensiv...

  • Besonders witzig ist es doch immer, den Code "anzupassen"...nur mal so als Beispiel bei Welle 200 seid ihr mit einem treffer tot xD
    Sorry, aber die Deklarationen am Anfang laden doch regelrecht dazu ein.
    Mal zurück zum Thema...sieht echt schön aus wusste gar nicht, das so etwas mit AutoIt überhaupt möglich ist.
    Frage: Darf ich den Code etwas anpassen? Bin gerade dabei, eine Minigamesammlung zusammenzustellen und
    da sind die Figuren etc. halt immer im NeonDesign welches ich hier ja vieleicht auch irgendwie hinkriegen könnte (dafür muss ich aber erst
    ein Paar GDI+ Tuts durcharbeiten).

    Bild1: Ich beim debuggen

  • Zitat

    Darf ich den Code etwas anpassen?


    Klar, solange du nicht einfach nur meinen Namen durch deinen Ersetzt (in dem Teil steckt nämlich ganz schön viel Arbeit) :P.

    Zitat

    Sorry, aber die Deklarationen am Anfang laden doch regelrecht dazu ein.


    Die waren auch dazu gedacht, weil ich das Spiel nie wirklich fertig bekommen hab. Die Attribute die für die Gegner bei jedem Level generiert werden waren am Anfang nur zu Testzwecken (ich wollte das später als Survival Modus drinlassen).

  • hay!

    erstmal ein riesen lob an dich - ich hätte auch nicht gedacht, dass sowas möglich ist,
    allerdings hab ich nur bis wave - hmm glaub 12 oder so - gespielt, bin nicht so gut in sowas :D war trotzdem witzig..

    ich versteh von Dlls usw sogut wie garnix, und bin auch mit Gdi+ nen ziemlicher Anfänger, aber ich hab mir gedacht,
    ich greif dir mal beim "aufräumen" bisschen unter die Arme:

    Du hast ja am Anfang vom Script folgenden Code für alle Menüpunkte:

    [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, "Continue", $hFont_Menu, _GDIPlus_RectFCreate(0, 100), $hStringFormat)
    $tLayout_Menu_Continue = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tLayout_Menu_Continue, "X", $iGUIWidth / 2 - DllStructGetData($tLayout_Menu_Continue, "Width") / 2)
    DllStructSetData($tLayout_Menu_Continue, "Width", DllStructGetData($tLayout_Menu_Continue, "Width") + 1)

    [/autoit]

    das habe ich jetzt ersetzt durch:

    [autoit]

    $tLayout_Menu_Continue = _CreateMenuItem("Continue",100)
    $tLayout_Menu_Start = _CreateMenuItem("Start",100)
    $tLayout_Menu_Options = _CreateMenuItem("Options",150)
    $tLayout_Menu_Quit = _CreateMenuItem("Quit",200)

    [/autoit]

    und dann weiter unten bei den Funktionen:

    [autoit]

    Func _CreateMenuItem($sText,$iHeight)
    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphic, $sText, $hFont_Menu, _GDIPlus_RectFCreate(0, $iHeight), $hStringFormat)
    $tMenuItem = $aMeasure[0]
    $aMeasure = ""
    DllStructSetData($tMenuItem, "X", $iGUIWidth / 2 - DllStructGetData($tMenuItem, "Width") / 2)
    DllStructSetData($tMenuItem, "Width", DllStructGetData($tMenuItem, "Width") + 1)
    Return $tMenuItem
    EndFunc ;==>_CreateMenuItem

    [/autoit]

    weil ich finde, dass man das nicht x-mal schreiben braucht (ich bin zwar auch ein fan von copy & paste, allerdings nur von 1script ins andre ;) )
    da ich Options hinzugefügt habe, muss man natürlich noch die _Pause() funktion entsprechend anpassen:

    [autoit]

    Switch _PointIsInRect($aCursorInfo[0], $aCursorInfo[1], DllStructGetData($tLayout_Menu_Options, "X"), DllStructGetData($tLayout_Menu_Options, "Y"), DllStructGetData($tLayout_Menu_Options, "Width"), DllStructGetData($tLayout_Menu_Options, "Height"))
    Case True
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Options", $hFont_Menu, $tLayout_Menu_Options, $hStringFormat, $hBrush_MenuTextHighlight)
    If $aCursorInfo[2] Then _Options()
    Case False
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Options", $hFont_Menu, $tLayout_Menu_Options, $hStringFormat, $hBrush_MenuTextNormal)
    EndSwitch

    [/autoit]


    wobei ich finde, dass man das mit dem Hover usw auch schon fast wieder auslagern könnte..

    hm das mach ich gleich mal (schon dumm wenn man während dem schreiben dann doch noch was ändert.. naja dauer ja ned lang)

    ...

    okay, fertig ;)

    der Teil in _Pause():

    [autoit]

    Switch $bNewGame
    Case True
    If _DrawMenuItem($tLayout_Menu_Start,"Start") Then ExitLoop
    Case False
    If _DrawMenuItem($tLayout_Menu_Continue,"Continue") Then ExitLoop
    EndSwitch
    If _DrawMenuItem($tLayout_Menu_Options,"Options") Then _Options()
    If _DrawMenuItem($tLayout_Menu_Quit,"Quit") Then _Close()

    [/autoit]

    und die Funktion zu:

    [autoit]

    Func _DrawMenuItem(ByRef $tMenuItem,$sText)
    Switch _PointIsInRect($aCursorInfo[0], $aCursorInfo[1], DllStructGetData($tMenuItem, "X"), DllStructGetData($tMenuItem, "Y"), DllStructGetData($tMenuItem, "Width"), DllStructGetData($tMenuItem, "Height"))
    Case True
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont_Menu, $tMenuItem, $hStringFormat, $hBrush_MenuTextHighlight)
    If $aCursorInfo[2] Then Return True ; geklickt
    Case False
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont_Menu, $tMenuItem, $hStringFormat, $hBrush_MenuTextNormal)
    EndSwitch
    Return False
    EndFunc ;==>_DrawMenuItem

    [/autoit]


    (gibt True zurück, wenn geklickt wurde, und False, wenn nicht)

    ich kenn das Schüler-Problem übrigends auch, bin in der gleichen Lage...
    aber würd, wenn ich Zeit hab, gerne immermal wieder bisschen helfen

    die Funktion _Options() ist momentan übrigends noch leer, mach ich nacher/nen andres mal...

    Gruß FR34Q

    P.S.: Wär nett, wenn du das ganze mit ; Kommentaren versehen könntest, damit andre auch durchblicken (naja ich verstehs ja eh nur vom prinzip, aber würde mir glaub schon helfen)

    edit: hatte übersehen, dass die cursor-infos ja nicht global sind, also das dann noch ändern (in _Pause() )

    [autoit]

    Global $aCursorInfo = GUIGetCursorInfo($hWnd)

    [/autoit]

    alternative: (wenn Global nicht gewünscht ist)

    [autoit]

    $aCursorInfo = GUIGetCursorInfo($hWnd)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmapBG, 0, 0, $iGUIWidth, $iGUIHeight)
    Switch $bNewGame
    Case True
    If _DrawMenuItem($tLayout_Menu_Start,"Start",$aCursorInfo) Then ExitLoop
    Case False
    If _DrawMenuItem($tLayout_Menu_Continue,"Continue",$aCursorInfo) Then ExitLoop
    EndSwitch
    If _DrawMenuItem($tLayout_Menu_Options,"Options",$aCursorInfo) Then _Options()
    If _DrawMenuItem($tLayout_Menu_Quit,"Quit",$aCursorInfo) Then _Close()

    [/autoit]

    und bei der Funktion dann:

    [autoit]

    Func _DrawMenuItem(ByRef $tMenuItem,$sText,$aCursorInfo=-1)
    If $aCursorInfo=-1 Then $aCursorInfo=GUIGetCursorInfo($hWnd)
    Switch _PointIsInRect($aCursorInfo[0], $aCursorInfo[1], DllStructGetData($tMenuItem, "X"), DllStructGetData($tMenuItem, "Y"), DllStructGetData($tMenuItem, "Width"), DllStructGetData($tMenuItem, "Height"))
    Case True
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont_Menu, $tMenuItem, $hStringFormat, $hBrush_MenuTextHighlight)
    If $aCursorInfo[2] Then Return True ; geklickt
    Case False
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont_Menu, $tMenuItem, $hStringFormat, $hBrush_MenuTextNormal)
    EndSwitch
    Return False
    EndFunc ;==>_DrawMenuItem

    [/autoit]

    Einmal editiert, zuletzt von FR34Q (1. November 2011 um 20:48)