GDI Plus

  • Hi Leute...
    habe mal ne kleine Frage zu GDIPlus. Wie kann ich damit nen Punkt erstellen? Das einzigste was ich hinbekomme ist eine Linie aber mehr auch nicht :D
    ich kenne mich mit GDIPlus noch nicht so gut aus und wäre froh, wenn mir jemand ne antwort geben könnt ;)
    mfg Bio

  • Ok, das mit dem Kreis zeichnen hat sich erledigt, aber das mit dem ausmalen nicht :D

    • Offizieller Beitrag

    Guckst du in die Hilfe:

    [autoit]

    #include <GuiConstantsEx.au3>
    #include <GDIPlus.au3>

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

    Opt('MustDeclareVars', 1)

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

    _Main()
    Exit

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

    Func _Main()
    Local $hGUI, $hWnd, $hGraphic, $hBrush

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

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    $hWnd = WinGetHandle("GDI+")
    GUISetState()

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

    ; Draw an ellipse
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
    _GDIPlus_GraphicsFillEllipse ($hGraphic, 50, 50, 13, 13)

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

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    ; Clean up resources
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()

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

    EndFunc ;==>_Main

    [/autoit]
  • Ok, danke. Geht es eigentlich auch, dass sich diese Elipse zu einem Strich immer weiterbewegt...
    Also ich meine, dass sich mehrere Elipsen aneinaderketten und das immer in einem regelmäßigen Abstand der Zeit.
    Wenn dazu jemand ne gute Antwort hätte...
    mfg Bio

    • Offizieller Beitrag

    So?

    [autoit]

    #include <GuiConstantsEx.au3>
    #include <GDIPlus.au3>

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

    Opt('MustDeclareVars', 1)

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

    _Main()
    Exit

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

    Func _Main()
    Local $hGUI, $hWnd, $hGraphic, $x = -2

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

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    $hWnd = WinGetHandle("GDI+")
    GUISetState()

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

    ; Draw an ellipse
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
    For $i = 1 To 25
    $x += 13
    _GDIPlus_GraphicsFillEllipse ($hGraphic, $x, 50, 13, 13)
    Sleep(300)
    Next

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

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    ; Clean up resources
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()

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

    EndFunc ;==>_Main

    [/autoit]
  • Ich hab es nochmal ein bischen verkleinert

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    ; Create GUI
    $hWnd = GUICreate("GDI+", 400, 300)
    GUISetState()

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

    ; Draw an ellipse
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
    For $i = 1 To 325 Step 13
    _GDIPlus_GraphicsFillEllipse ($hGraphic, $i, 50, 13, 13)
    Sleep(300)
    Next

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

    ; Loop until user exits
    Do
    Until GUIGetMsg() = -3

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

    ; Clean up resources
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()

    [/autoit]

    mfg. Jam00

  • ok, danke weiß zufällig jemand wie ich es hinbekommen kann, dass wenn sich 2 Linien berühren, dass dann ein Label kommt:"Game Over"?
    danke schonmal
    mfg Bio

  • also in meinem Skript gibt es eine Linie, die sich immer fortbewegt und die man beeinflussen kann. Und jetzt will ich erreichen, dass wenn sich diese Linie wieder berührt, dass dann das Label "Game Over" kommt.
    [Spoiler]

    [autoit]


    #include <guiconstants.au3>
    #include <Misc.au3>
    #include <gdiplus.au3>
    $main=GUICreate("",@desktopwidth,@desktopheight)
    GUISetState(@sw_show)
    GUISetBkColor(0x000000)
    $label=GUICtrlCreateLabel("Willkommen bei P@ Kurvenspiel",500,100,@desktopwidth,100)
    GUICtrlSetFont($label,30)
    $label2=GUICtrlCreateLabel("Einzelspieler",50,300,@desktopwidth,100)
    GUICtrlSetFont($label2,20)
    GUICtrlSetColor($label2,0xFFD000)
    GUICtrlSetColor($label,0x785463)

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

    while 1
    $msg=GUIGetMsg()
    Select
    case $msg=$gui_event_close
    exit 1
    case $msg=$label2
    GUIDelete($main)
    _neues()
    EndSelect
    WEnd

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

    ;Funktion _neues()
    Func _neues()
    $neues=GUICreate("",@desktopwidth,@desktopheight)
    GUISetState(@sw_show)
    Global $random=Random(50,1500,1)
    Global $random2=Random(50,800,1)
    AdlibEnable("_pressed",1000)
    $handle= WinGetHandle ("")

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

    ;GDIPlus für Elipse
    _GDIPlus_Startup()
    $graphic=_GDIPlus_GraphicsCreateFromHWND($handle)
    For $i=1 To 1000000000000
    $random+=7

    ;if _IsPressed zum beeinflussen der Richtung
    if _IsPressed("26") Then
    $random-=7
    $random2-=7
    EndIf
    if _IsPressed("25") Then
    $random-=14
    EndIf
    if _IsPressed("28") Then
    $random-=7
    $random2+=7
    EndIf

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

    ;zeichnet Ellipse
    Global $elipse=_GDIPlus_GraphicsFillEllipse($graphic,$random,$random2,13,13)
    Global $X=$random
    Global $Y=$random
    Sleep(100)
    Next
    Do
    Until GUIGetMsg()=$gui_event_close
    _GDIPlus_GraphicsDispose($graphic)
    _GDIPlus_Shutdown()

    while 1
    $msg=GUIGetMsg()
    Select
    case $msg=$gui_event_close
    exit 1
    EndSelect
    WEnd
    EndFunc ;-> _neues()

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

    ;Funtion zum Beenden des Skripts
    Func _pressed()
    if _IsPressed("1B") Then
    exit 1
    EndIf
    EndFunc ;-> _pressed()

    [/autoit]
  • Also ich habe es mal ein bischen ausgebessert, aber das mit der Line ist noch nicht drin

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>
    #include <gdiplus.au3>
    $main= GUICreate("",@desktopwidth,@desktopheight,-3,-29)
    GUISetState(@sw_show)
    GUISetBkColor(0x000000)
    $label=GUICtrlCreateLabel("Willkommen bei P@ Kurvenspiel",500,100,@desktopwidth,100)
    GUICtrlSetFont($label,30)
    $label2=GUICtrlCreateLabel("Einzelspieler",50,300,@desktopwidth,100)
    GUICtrlSetFont($label2,20)
    GUICtrlSetColor($label2,0xFFD000)
    GUICtrlSetColor($label,0x785463)

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

    while 1
    $msg=GUIGetMsg()
    Switch $msg
    case -3
    exit
    case $label2
    GUIDelete($main)
    _neues()
    EndSwitch
    WEnd

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

    ;Funktion _neues()
    Func _neues()
    $neues=GUICreate("",@desktopwidth,@desktopheight,-3,-29)
    GUISetState(@sw_show)
    $random=Random(50,1500,1)
    $random2=Random(50,800,1)
    AdlibEnable("_pressed",1000)

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

    ;GDIPlus für Elipse
    _GDIPlus_Startup()
    $graphic=_GDIPlus_GraphicsCreateFromHWND($neues)
    For $i=1 To 1000000000000
    $random +=7

    ;if _IsPressed zum beeinflussen der Richtung
    if _IsPressed("26") Then
    $random -=7
    $random2 -=7
    EndIf
    if _IsPressed("25") Then
    $random -=14
    EndIf
    if _IsPressed("28") Then
    $random -=7
    $random2 +=7
    EndIf

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

    ;zeichnet Ellipse
    $elipse=_GDIPlus_GraphicsFillEllipse($graphic,$random,$random2,13,13)
    $X=$random
    $Y=$random
    Sleep(100)
    Next
    Do
    Until GUIGetMsg()= -3
    _GDIPlus_GraphicsDispose($graphic)
    _GDIPlus_Shutdown()

    while 1
    $msg=GUIGetMsg()
    Switch $msg
    case -3
    exit
    EndSwitch
    WEnd
    EndFunc ;-> _neues()

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

    ;Funtion zum Beenden des Skripts
    Func _pressed()
    if _IsPressed("1B") Then
    exit
    EndIf
    EndFunc ;-> _pressed()

    [/autoit]

    mfg. Jam00

  • ok, danke, haste auch noch ne idee wie man das mit der Linie machen kann ?
    und dass ich es machen kann, dass es nicht über den Desktoprand geht :D
    mfg Bio

  • Warum fragst du nicht gleich ob wir dir das ganze Script machen.

    Ich hab ma was gebastelt

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    #include <GDIPlus.au3>

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

    HotKeySet("{ESC}", "_exit")
    HotKeySet("{Left}", "_left")
    HotKeySet("{right}", "_right")
    HotKeySet("{up}", "_up")
    HotKeySet("{down}", "_down")

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

    Global $faktorx = 7, $faktory = 0, $randomx = Random(50, 1500, 1), $randomy = Random(50, 800, 1), $buffer = ''
    Dim $posarray[1]

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

    $main = GUICreate("", @DesktopWidth, @DesktopHeight, -3, -29)
    GUISetBkColor(0x000000)

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

    $label = GUICtrlCreateLabel("Willkommen bei Snake", 500, 100, 430, 100)
    GUICtrlSetColor(-1, 0x785463)
    GUICtrlSetFont(-1, 30)

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

    $label2 = GUICtrlCreateLabel("Einzelspieler", 50, 300, @DesktopWidth, 100)
    GUICtrlSetFont(-1, 20)
    GUICtrlSetColor(-1, 0xFFD000)

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

    GUISetState(@SW_SHOW)

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

    _GDIPlus_Startup()
    $graphic = _GDIPlus_GraphicsCreateFromHWND($main)

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

    While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case - 3
    Exit
    Case $label2
    GUICtrlSetData($label, "")
    GUICtrlDelete($label2)
    GUISetBkColor(0xFFFFFF, $main)
    AdlibEnable("_draw", 100)
    EndSwitch
    WEnd

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

    Func _draw()
    $randomx += $faktorx
    $randomy += $faktory

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

    _ArraySearch($posarray, $randomx & $randomy)
    If Not @error Then _gameover()

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

    If $buffer <> $randomx & $randomy Then _
    _ArrayAdd($posarray, $randomx & $randomy)

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

    If $randomx >= @DesktopWidth Then _gameover()
    If $randomx <= 0 Then _gameover()
    If $randomy >= @DesktopHeight Then _gameover()
    If $randomy <= 0 Then _gameover()

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

    $buffer = $randomx & $randomy

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

    _GDIPlus_GraphicsFillEllipse($graphic, $randomx, $randomy, 14, 14)
    EndFunc ;==>_draw

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

    Func _exit()
    ;~ _GDIPlus_GraphicsDispose($graphic)
    ;~ _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_exit

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

    Func _left()
    If ($faktorx <> -7) And ($faktory <> 0) Then
    $faktorx = -7
    $faktory = 0
    EndIf
    EndFunc ;==>_left

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

    Func _up()
    If ($faktorx <> 0) And ($faktory <> -7) Then
    $faktorx = 0
    $faktory = -7
    EndIf
    EndFunc ;==>_up

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

    Func _down()
    If ($faktorx <> 0) And ($faktory <> 7) Then
    $faktorx = 0
    $faktory = 7
    EndIf
    EndFunc ;==>_down

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

    Func _right()
    If ($faktorx <> 7) And ($faktory <> 0) Then
    $faktorx = 7
    $faktory = 0
    EndIf
    EndFunc ;==>_right

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

    Func _gameover()
    GUICtrlSetData($label, "Gameover")
    AdlibDisable()
    EndFunc ;==>_gameover

    [/autoit]