GDI + Buffer ?

  • Habe mal Pong in Autoit mit GDI + programmiert und läuft auch.
    Nur mein Probleme :

    a) Ist die Spielgeschwindigkeit mal schnell mal langsam
    b) Flackert manchmal zb der Ball oder die Punkte Anzeige

    Gibt es eine Möglichkeit zb alles in einen "Buffer" zu schreiben und das Bild im gesamten Auszugeben?
    Oder wie bekomme ich eine gleichmäßige Spielgeschwindigkeit hin?

    Einmal editiert, zuletzt von Aldi (17. Juli 2012 um 16:37)

  • Für das Ruckeln im Spiel gibt es mehrere Gründe:
    (Also das Mal schnell, mal langsam)

    1. Wahrscheinlich benutzt du irgendwo GuiGetMsg.
    Diese Funktion beinhaltet ein variables Sleep. Wenn du die Maus bewegst könnte ja etwas passieren, und die Wartezeit wird verkürzt.
    Das hilt wenn man z.B. ein GUI bauen will. Dann braucht man kein Sleep.

    2. Sleep arbeitet nur in 10er schritten und ist allgemein relativ ungenau.
    Wenn du die Sleepzeit variierst kommt es zu starken Geschwindigkeitsschwankungen.

    Um Punkt 1 zu beheben musst du dein GUI im OnEventMode verwalten.

    Punkt 2 kann man mit einem Workaround relativ gut beheben.
    Um z.B. 15ms zu warten kann man entweder Sleep(15) nutzen, was nicht funktioniert, oder beim ersten Mal Sleep(10) und beim 2ten Mal Sleep(20).
    Die Variante mit den glatt durch 10 teilbaren Sleeps ruckelt theoretisch extrem stark, aber in so kleinen Abständen, dass man es idr nicht sehen kann.

    Dazu gibts folgendes Beispiel.

    Spoiler anzeigen
    [autoit]

    Global $FPS = 0
    Global $Timer = TimerInit()

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

    While _FPS(37) ; Einfach eine Zahl reinschreiben und die Schleife wird in einer ähnlichen Geschwindigkeit laufen.
    $FPS += 1
    If TimerDiff($Timer) >= 1000 Then
    ConsoleWrite('> ' & $FPS & @CRLF)
    $FPS = 0
    $Timer = TimerInit()
    EndIf
    WEnd

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

    Func _FPS($W)
    Local Static $_t = TimerInit(), $f
    Local $s = TimerDiff($_t), $l = (1000 / $W - $s)
    $f += $l
    If $f < 0 Then $f = 0
    If $l < 0 Then $l = 0
    Sleep(Int($f / 10) * 10)
    $f -= Int($f / 10) * 10
    $_t = TimerInit()
    Return $s / ($s + $l)
    EndFunc

    [/autoit]

    Damit kann man die Framerate beliebig einstellen.
    Soweit es AutoIt geschwindigkeitsmäßig zulässt wird versucht diese Framerate einzuhalten. (Bei höherer Auslastung wird automatisch weniger geschlafen).

    Edit: Es ist immer praktisch ein Skript zu posten.
    Zu b)
    Genau diese Möglichkeit gibt es. Nennt sich Backbuffer.
    [ gelöst ] GDI+ Backbuffer - aber wie?!

  • Ok so klappt alles :)

    Hier ist das Script :

    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Icon=ping-pong.ico
    #AutoIt3Wrapper_Compression=4
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_Res_Description=Pong by Aldi
    #AutoIt3Wrapper_Res_Fileversion=1
    #AutoIt3Wrapper_Res_SaveSource=y
    #AutoIt3Wrapper_Res_Language=1031
    #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <GuiConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <Misc.au3>

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

    Global $graphics
    Global $bitmap
    Global $backbuffer

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

    Opt("GUIOnEventMode",1)

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

    Global $points_p1 = 0 , $points_p2 = 0
    Dim $ball[2]
    $ball[0] = 282
    $ball[1] = 180
    Global $ball_direction[2]
    $ball_direction[0] = 0
    $ball_direction[1] = 0
    Global $p1 = 100 , $p2 = 200

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

    _GDIPlus_Startup()
    $hGUI = GUICreate("Pong", 600, 400)
    $graphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $bitmap = _GDIPlus_BitmapCreateFromGraphics(600,400, $graphics)
    $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
    GUISetBkColor(0x000000)
    GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
    GUISetState()
    draw_points(1)
    draw_player()
    draw_ball(1)
    draw_middlane()
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0,600,400)

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

    Do
    Sleep(10)
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
    Until _IsPressed(20)
    While _IsPressed(20)
    Sleep(10)
    WEnd
    $ball_direction[0] = Random(1,2,1)
    $ball_direction[1] = Random(1,2,1)
    While _FPS(100)
    If WinActive($hGUI) Then

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

    If _IsPressed(26) Then move_p1up()
    If _IsPressed(28) Then move_p1down()
    If _IsPressed(57) Then move_p2up()
    If _IsPressed(53) Then move_p2down()
    game()
    collision()
    EndIf
    WEnd

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

    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_Shutdown()

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

    #region Funktionen

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

    Func _exit()
    Exit
    EndFunc

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

    Func _FPS($W)
    Local Static $_t = TimerInit(), $f
    Local $s = TimerDiff($_t), $l = (1000 / $W - $s)
    $f += $l
    If $f < 0 Then $f = 0
    If $l < 0 Then $l = 0
    Sleep(Int($f / 10) * 10)
    $f -= Int($f / 10) * 10
    $_t = TimerInit()
    Return $s / ($s + $l)
    EndFunc

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

    Func game()
    ;~ $timer=TimerInit()
    ;~ Do
    ;~ $diff = TimerDiff($timer)
    ;~ Until $diff >= 10
    If $ball_direction[0] = 1 and $ball_direction[1] = 1 Then
    draw_ball(0)
    $ball[0] = $ball[0]-1
    $ball[1] = $ball[1]-1
    draw_ball(1)
    draw_points(1)
    If $ball[1] = 15 Then $ball_direction[1] = 2
    ElseIf $ball_direction[0] = 1 and $ball_direction[1] = 2 Then
    draw_ball(0)
    $ball[0] = $ball[0]-1
    $ball[1] = $ball[1]+1
    draw_ball(1)
    draw_points(1)
    If $ball[1] = 380 Then $ball_direction[1] = 1
    ElseIf $ball_direction[0] = 2 and $ball_direction[1] = 1 Then
    draw_ball(0)
    $ball[0] = $ball[0]+1
    $ball[1] = $ball[1]-1
    draw_ball(1)
    draw_points(1)
    If $ball[1] = 15 Then $ball_direction[1] = 2
    ElseIf $ball_direction[0] = 2 and $ball_direction[1] = 2 Then
    draw_ball(0)
    $ball[0] = $ball[0]+1
    $ball[1] = $ball[1]+1
    draw_ball(1)
    draw_points(1)
    If $ball[1] = 380 Then $ball_direction[1] = 1
    EndIf
    draw_middlane()
    draw_player()
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0,600,400)
    EndFunc

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

    Func draw_player()
    $hPen = _GDIPlus_PenCreate(0xFFFFFFFF,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer,40,$p1,40,$p1+50,$hPen)
    _GDIPlus_GraphicsDrawLine ($backbuffer,560,$p2,560,$p2+50,$hPen)
    _GDIPlus_PenDispose($hPen)
    EndFunc

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

    Func draw_gamefield()
    $hPen = _GDIPlus_PenCreate(0xFFFFFFFF,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer, 15,10, 585, 10, $hPen)
    _GDIPlus_GraphicsDrawLine ($backbuffer, 15,390, 585, 390, $hPen)
    _GDIPlus_GraphicsDrawLine ($backbuffer, 17,10, 17, 392, $hPen)
    _GDIPlus_GraphicsDrawLine ($backbuffer, 582,10, 582, 392, $hPen)
    _GDIPlus_PenDispose($hPen)
    EndFunc

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

    Func draw_middlane()
    $hPen = _GDIPlus_PenCreate(0xFFFFFFFF,2)
    For $y = 10 to 392
    _GDIPlus_GraphicsDrawLine ($backbuffer,285,$y, 285,$y + 5, $hPen)
    $y = $y + 10
    Next
    _GDIPlus_PenDispose($hPen)
    EndFunc

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

    Func draw_points($sSetting)
    if $sSetting = 0 Then
    _GDIPlus_GraphicsClear($backbuffer)
    ElseIf $sSetting = 1 Then
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Verdana")
    $hFont = _GDIPlus_FontCreate($hFamily, 30, 0)
    $tLayout = _GDIPlus_RectFCreate(200,10,600,400)
    $aInfo = _GDIPlus_GraphicsMeasureString($backbuffer,$points_p1, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($backbuffer,$points_p1, $hFont, $aInfo[0], $hFormat, $hBrush)
    $tLayout = _GDIPlus_RectFCreate(288,10,600,400)
    $aInfo = _GDIPlus_GraphicsMeasureString($backbuffer,$points_p2, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($backbuffer,$points_p2, $hFont, $aInfo[0], $hFormat, $hBrush)
    $hBrush = _GDIPlus_BrushCreateSolid(0x45FF0000)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Verdana")
    $hFont = _GDIPlus_FontCreate($hFamily, 30, 0)
    $tLayout = _GDIPlus_RectFCreate(200,10,600,400)
    $aInfo = _GDIPlus_GraphicsMeasureString($backbuffer,$points_p1, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($backbuffer,$points_p1, $hFont, $aInfo[0], $hFormat, $hBrush)
    $tLayout = _GDIPlus_RectFCreate(288,10,600,400)
    $aInfo = _GDIPlus_GraphicsMeasureString($backbuffer,$points_p2, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($backbuffer,$points_p2, $hFont, $aInfo[0], $hFormat, $hBrush)
    EndIf
    draw_gamefield()
    EndFunc

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

    Func move_p1up()
    If $p1 = 15 Then
    Else
    $hPen = _GDIPlus_PenCreate(0xFF000000,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer,40,$p1,40,$p1+50,$hPen)
    _GDIPlus_PenDispose($hPen)
    $p1 = $p1 - 1
    draw_player()
    EndIf
    EndFunc

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

    Func move_p1down()
    If $p1 = 335 Then
    Else
    $hPen = _GDIPlus_PenCreate(0xFF000000,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer,40,$p1,40,$p1+50,$hPen)
    _GDIPlus_PenDispose($hPen)
    $p1 = $p1 + 1
    draw_player()
    EndIf
    EndFunc

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

    Func move_p2up()
    If $p2 = 15 Then
    Else
    $hPen = _GDIPlus_PenCreate(0xFF000000,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer,560,$p2,560,$p2+50,$hPen)
    _GDIPlus_PenDispose($hPen)
    $p2 = $p2 - 1
    draw_player()
    EndIf
    EndFunc

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

    Func move_p2down()
    If $p2 = 335 Then
    Else
    $hPen = _GDIPlus_PenCreate(0xFF000000,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer,560,$p2,560,$p2+50,$hPen)
    _GDIPlus_PenDispose($hPen)
    $p2 = $p2 + 1
    draw_player()
    EndIf
    EndFunc

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

    Func collision()
    If $ball[0] = 22 Then
    draw_points(0)
    $points_p2 = $points_p2 + 1
    draw_ball(0)
    $ball[0] = 282
    $ball[1] = 180
    $ball_direction[0] = 2
    $ball_direction[1] = Random(1,2,1)
    draw_points(1)
    ElseIf $ball[0] = 572 Then
    draw_points(0)
    $points_p1 = $points_p1 + 1
    draw_ball(0)
    $ball[0] = 282
    $ball[1] = 180
    $ball_direction[0] = 1
    $ball_direction[1] = Random(1,2,1)
    draw_points(1)
    EndIf
    If $ball[0] = 46 Then
    If $ball[1] > $p1 and $ball[1] < $p1 + 50 Then
    $ball_direction[0] = 2
    EndIf
    ElseIf $ball[0] = 549 Then
    If $ball[1] > $p2 and $ball[1] < $p2 + 50 Then
    $ball_direction[0] = 1
    EndIf
    EndIf
    EndFunc

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

    Func draw_ball($sSetting)
    If $sSetting = 0 Then
    $hPen = _GDIPlus_PenCreate(0xFF000000,5)
    _GDIPlus_GraphicsDrawRect($backbuffer,$ball[0],$ball[1],5,5,$hPen)
    _GDIPlus_PenDispose($hPen)
    ElseIf $sSetting = 1 Then
    $hPen = _GDIPlus_PenCreate(0xFFFFFFFF,5)
    _GDIPlus_GraphicsDrawRect($backbuffer,$ball[0],$ball[1],5,5,$hPen)
    _GDIPlus_PenDispose($hPen)
    EndIf
    EndFunc

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

    #endregion

    [/autoit]

    Auf besondere Schönheit oder Ordnung innerhalb des Script habe ich nicht geachtet;)

    Wie könnte ich das Spiel noch schneller bekommen ? Denn so daddelt es noch etwas vor sich hin ;:D

  • Die Geschwindigkeit hängt immer von 2 Faktoren ab.

    Wie groß die Sprünge sind die dein Spiel macht und wie oft diese Sprünge gemacht werden.

    zum Beispiel der Ball:
    In deinen Einstellungen läuft das Spiel mit 100 FPS (das ist extrem schnell und mit GDI+ nicht empfehlenswert^^).
    Der Ball macht aber pro Frame nur einen einzigen Sprung von einem Pixel.
    Bei 100 FPS sind das nur 100px/Sek.
    Bei einem Handelsüblichen Bildschirm sind das fast 20 Sekunden um auf die andere Seite zu kommen.

    Hab dein Skript mal etwas abgeändert.
    Jetzt läuft es mit 50 FPS und 3px schritten. (das ist 1,5Mal so schnell wie vorher)
    Idr reichen sogar 25 FPS aus. Aber dann sieht man dieses Ruckeln was ich oben erwähnt habe. Bei 50 ist das schon minimal.

    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Icon=ping-pong.ico
    #AutoIt3Wrapper_Compression=4
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_Res_Description=Pong by Aldi
    #AutoIt3Wrapper_Res_Fileversion=1
    #AutoIt3Wrapper_Res_SaveSource=y
    #AutoIt3Wrapper_Res_Language=1031
    #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <GuiConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <Misc.au3>

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

    Global $graphics
    Global $bitmap
    Global $backbuffer

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

    Opt("GUIOnEventMode",1)

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

    Global $iSpeed = 3

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

    Global $points_p1 = 0 , $points_p2 = 0
    Dim $ball[2]
    $ball[0] = 282
    $ball[1] = 180
    Global $ball_direction[2]
    $ball_direction[0] = 0
    $ball_direction[1] = 0
    Global $p1 = 100 , $p2 = 200

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

    _GDIPlus_Startup()
    $hGUI = GUICreate("Pong", 600, 400)
    $graphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $bitmap = _GDIPlus_BitmapCreateFromGraphics(600,400, $graphics)
    $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
    GUISetBkColor(0x000000)
    GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
    GUISetState()
    draw_points(1)
    draw_player()
    draw_ball(1)
    draw_middlane()
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0,600,400)

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

    Do
    Sleep(10)
    ;~ If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
    Until _IsPressed(20)
    While _IsPressed(20)
    Sleep(10)
    WEnd

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

    $ball_direction[0] = Random(1,2,1)
    $ball_direction[1] = Random(1,2,1)

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

    While _FPS(50)
    If WinActive($hGUI) Then
    If _IsPressed(26) Then move_p1up()
    If _IsPressed(28) Then move_p1down()
    If _IsPressed(57) Then move_p2up()
    If _IsPressed(53) Then move_p2down()
    game()
    collision()
    EndIf
    WEnd

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

    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_Shutdown()

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

    #region Funktionen

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

    Func _exit()
    Exit
    EndFunc

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

    Func _FPS($W)
    Local Static $_t = TimerInit(), $f
    Local $s = TimerDiff($_t), $l = (1000 / $W - $s)
    $f += $l
    If $f < 0 Then $f = 0
    If $l < 0 Then $l = 0
    Sleep(Int($f / 10) * 10)
    $f -= Int($f / 10) * 10
    $_t = TimerInit()
    Return $s / ($s + $l)
    EndFunc

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

    Func game()
    ;~ $timer=TimerInit()
    ;~ Do
    ;~ $diff = TimerDiff($timer)
    ;~ Until $diff >= 10
    If $ball_direction[0] = 1 and $ball_direction[1] = 1 Then
    draw_ball(0)
    $ball[0] = $ball[0]-$iSpeed
    $ball[1] = $ball[1]-$iSpeed
    draw_ball(1)
    draw_points(1)
    If $ball[1] <= 15 Then $ball_direction[1] = 2
    ElseIf $ball_direction[0] = 1 and $ball_direction[1] = 2 Then
    draw_ball(0)
    $ball[0] = $ball[0]-$iSpeed
    $ball[1] = $ball[1]+$iSpeed
    draw_ball(1)
    draw_points(1)
    If $ball[1] >= 380 Then $ball_direction[1] = 1
    ElseIf $ball_direction[0] = 2 and $ball_direction[1] = 1 Then
    draw_ball(0)
    $ball[0] = $ball[0]+$iSpeed
    $ball[1] = $ball[1]-$iSpeed
    draw_ball(1)
    draw_points(1)
    If $ball[1] <= 15 Then $ball_direction[1] = 2
    ElseIf $ball_direction[0] = 2 and $ball_direction[1] = 2 Then
    draw_ball(0)
    $ball[0] = $ball[0]+$iSpeed
    $ball[1] = $ball[1]+$iSpeed
    draw_ball(1)
    draw_points(1)
    If $ball[1] >= 380 Then $ball_direction[1] = 1
    EndIf
    draw_middlane()
    draw_player()
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0,600,400)
    EndFunc

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

    Func draw_player()
    $hPen = _GDIPlus_PenCreate(0xFFFFFFFF,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer,40,$p1,40,$p1+50,$hPen)
    _GDIPlus_GraphicsDrawLine ($backbuffer,560,$p2,560,$p2+50,$hPen)
    _GDIPlus_PenDispose($hPen)
    EndFunc

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

    Func draw_gamefield()
    $hPen = _GDIPlus_PenCreate(0xFFFFFFFF,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer, 15,10, 585, 10, $hPen)
    _GDIPlus_GraphicsDrawLine ($backbuffer, 15,390, 585, 390, $hPen)
    _GDIPlus_GraphicsDrawLine ($backbuffer, 17,10, 17, 392, $hPen)
    _GDIPlus_GraphicsDrawLine ($backbuffer, 582,10, 582, 392, $hPen)
    _GDIPlus_PenDispose($hPen)
    EndFunc

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

    Func draw_middlane()
    $hPen = _GDIPlus_PenCreate(0xFFFFFFFF,2)
    For $y = 10 to 392
    _GDIPlus_GraphicsDrawLine ($backbuffer,285,$y, 285,$y + 5, $hPen)
    $y = $y + 10
    Next
    _GDIPlus_PenDispose($hPen)
    EndFunc

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

    Func draw_points($sSetting)
    if $sSetting = 0 Then
    _GDIPlus_GraphicsClear($backbuffer)
    ElseIf $sSetting = 1 Then
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Verdana")
    $hFont = _GDIPlus_FontCreate($hFamily, 30, 0)
    $tLayout = _GDIPlus_RectFCreate(200,10,600,400)
    $aInfo = _GDIPlus_GraphicsMeasureString($backbuffer,$points_p1, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($backbuffer,$points_p1, $hFont, $aInfo[0], $hFormat, $hBrush)
    $tLayout = _GDIPlus_RectFCreate(288,10,600,400)
    $aInfo = _GDIPlus_GraphicsMeasureString($backbuffer,$points_p2, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($backbuffer,$points_p2, $hFont, $aInfo[0], $hFormat, $hBrush)
    $hBrush = _GDIPlus_BrushCreateSolid(0x45FF0000)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Verdana")
    $hFont = _GDIPlus_FontCreate($hFamily, 30, 0)
    $tLayout = _GDIPlus_RectFCreate(200,10,600,400)
    $aInfo = _GDIPlus_GraphicsMeasureString($backbuffer,$points_p1, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($backbuffer,$points_p1, $hFont, $aInfo[0], $hFormat, $hBrush)
    $tLayout = _GDIPlus_RectFCreate(288,10,600,400)
    $aInfo = _GDIPlus_GraphicsMeasureString($backbuffer,$points_p2, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($backbuffer,$points_p2, $hFont, $aInfo[0], $hFormat, $hBrush)
    EndIf
    draw_gamefield()
    EndFunc

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

    Func move_p1up()
    If $p1 <= 15 Then
    Else
    $hPen = _GDIPlus_PenCreate(0xFF000000,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer,40,$p1,40,$p1+50,$hPen)
    _GDIPlus_PenDispose($hPen)
    $p1 = $p1 - $iSpeed
    draw_player()
    EndIf
    EndFunc

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

    Func move_p1down()
    If $p1 >= 335 Then
    Else
    $hPen = _GDIPlus_PenCreate(0xFF000000,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer,40,$p1,40,$p1+50,$hPen)
    _GDIPlus_PenDispose($hPen)
    $p1 = $p1 + $iSpeed
    draw_player()
    EndIf
    EndFunc

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

    Func move_p2up()
    If $p2 <= 15 Then
    Else
    $hPen = _GDIPlus_PenCreate(0xFF000000,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer,560,$p2,560,$p2+50,$hPen)
    _GDIPlus_PenDispose($hPen)
    $p2 = $p2 - $iSpeed
    draw_player()
    EndIf
    EndFunc

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

    Func move_p2down()
    If $p2 >= 335 Then
    Else
    $hPen = _GDIPlus_PenCreate(0xFF000000,5)
    _GDIPlus_GraphicsDrawLine ($backbuffer,560,$p2,560,$p2+50,$hPen)
    _GDIPlus_PenDispose($hPen)
    $p2 = $p2 + $iSpeed
    draw_player()
    EndIf
    EndFunc

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

    Func collision()
    If $ball[0] <= 22 Then
    draw_points(0)
    $points_p2 = $points_p2 + 1
    draw_ball(0)
    $ball[0] = 282
    $ball[1] = 180
    $ball_direction[0] = 2
    $ball_direction[1] = Random(1,2,1)
    draw_points(1)
    ElseIf $ball[0] >= 572 Then
    draw_points(0)
    $points_p1 = $points_p1 + 1
    draw_ball(0)
    $ball[0] = 282
    $ball[1] = 180
    $ball_direction[0] = 1
    $ball_direction[1] = Random(1,2,1)
    draw_points(1)
    EndIf
    If $ball[0] <= 46 Then
    If $ball[1] > $p1 and $ball[1] < $p1 + 50 Then
    $ball_direction[0] = 2
    EndIf
    ElseIf $ball[0] >= 549 Then
    If $ball[1] > $p2 and $ball[1] < $p2 + 50 Then
    $ball_direction[0] = 1
    EndIf
    EndIf
    EndFunc

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

    Func draw_ball($sSetting)
    If $sSetting = 0 Then
    $hPen = _GDIPlus_PenCreate(0xFF000000,5)
    _GDIPlus_GraphicsDrawRect($backbuffer,$ball[0],$ball[1],5,5,$hPen)
    _GDIPlus_PenDispose($hPen)
    ElseIf $sSetting = 1 Then
    $hPen = _GDIPlus_PenCreate(0xFFFFFFFF,5)
    _GDIPlus_GraphicsDrawRect($backbuffer,$ball[0],$ball[1],5,5,$hPen)
    _GDIPlus_PenDispose($hPen)
    EndIf
    EndFunc

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

    #endregion

    [/autoit]