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
ich kenne mich mit GDIPlus noch nicht so gut aus und wäre froh, wenn mir jemand ne antwort geben könnt
mfg Bio
GDI Plus
-
- [ offen ]
-
Bio Drink -
15. April 2009 um 23:07 -
Geschlossen -
Erledigt
-
-
- Offizieller Beitrag
Einfach einen Kreis mit 'nem kleinen Durchmesser zeichnen und ausfüllen.
-
und wie zeichne ich so einen Kreis und fülle ihn aus
-
Ok, das mit dem Kreis zeichnen hat sich erledigt, aber das mit dem ausmalen nicht
-
- Offizieller Beitrag
Guckst du in die Hilfe:
[autoit]#include <GuiConstantsEx.au3>
[/autoit][autoit][/autoit][autoit]
#include <GDIPlus.au3>Opt('MustDeclareVars', 1)
[/autoit][autoit][/autoit][autoit]_Main()
[/autoit][autoit][/autoit][autoit]
ExitFunc _Main()
[/autoit][autoit][/autoit][autoit]
Local $hGUI, $hWnd, $hGraphic, $hBrush; Create GUI
[/autoit][autoit][/autoit][autoit]
$hGUI = GUICreate("GDI+", 400, 300)
$hWnd = WinGetHandle("GDI+")
GUISetState(); Draw an ellipse
[/autoit][autoit][/autoit][autoit]
_GDIPlus_Startup ()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
_GDIPlus_GraphicsFillEllipse ($hGraphic, 50, 50, 13, 13); Loop until user exits
[/autoit][autoit][/autoit][autoit]
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE; Clean up resources
[/autoit][autoit][/autoit][autoit]
_GDIPlus_GraphicsDispose ($hGraphic)
_GDIPlus_Shutdown ()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>
[/autoit][autoit][/autoit][autoit]
#include <GDIPlus.au3>Opt('MustDeclareVars', 1)
[/autoit][autoit][/autoit][autoit]_Main()
[/autoit][autoit][/autoit][autoit]
ExitFunc _Main()
[/autoit][autoit][/autoit][autoit]
Local $hGUI, $hWnd, $hGraphic, $x = -2; Create GUI
[/autoit][autoit][/autoit][autoit]
$hGUI = GUICreate("GDI+", 400, 300)
$hWnd = WinGetHandle("GDI+")
GUISetState(); Draw an ellipse
[/autoit][autoit][/autoit][autoit]
_GDIPlus_Startup ()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
For $i = 1 To 25
$x += 13
_GDIPlus_GraphicsFillEllipse ($hGraphic, $x, 50, 13, 13)
Sleep(300)
Next; Loop until user exits
[/autoit][autoit][/autoit][autoit]
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE; Clean up resources
[/autoit][autoit][/autoit][autoit]
_GDIPlus_GraphicsDispose ($hGraphic)
_GDIPlus_Shutdown ()EndFunc ;==>_Main
[/autoit] -
Vilen Dank für deine Hilfe jetzt ist alles klar
mfg Bio -
Ich hab es nochmal ein bischen verkleinert
Spoiler anzeigen
[autoit]#include <GDIPlus.au3>
[/autoit] [autoit][/autoit] [autoit]
; Create GUI
$hWnd = GUICreate("GDI+", 400, 300)
GUISetState(); Draw an ellipse
[/autoit] [autoit][/autoit] [autoit]
_GDIPlus_Startup ()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
For $i = 1 To 325 Step 13
_GDIPlus_GraphicsFillEllipse ($hGraphic, $i, 50, 13, 13)
Sleep(300)
Next; Loop until user exits
[/autoit] [autoit][/autoit] [autoit]
Do
Until GUIGetMsg() = -3; Clean up resources
[/autoit]
_GDIPlus_GraphicsDispose ($hGraphic)
_GDIPlus_Shutdown () -
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 -
Was für lienen? Und wie steht es mit dem Script?
Soll das Snacke werden? -
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.
[autoit]
[Spoiler]
[/autoit][autoit][/autoit][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)while 1
[/autoit][autoit][/autoit][autoit]
$msg=GUIGetMsg()
Select
case $msg=$gui_event_close
exit 1
case $msg=$label2
GUIDelete($main)
_neues()
EndSelect
WEnd;Funktion _neues()
[/autoit][autoit][/autoit][autoit][/autoit][autoit]
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 ("");GDIPlus für Elipse
[/autoit][autoit][/autoit][autoit]
_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;zeichnet Ellipse
[/autoit][autoit][/autoit][autoit]
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();Funtion zum Beenden des Skripts
[/autoit]
Func _pressed()
if _IsPressed("1B") Then
exit 1
EndIf
EndFunc ;-> _pressed() -
Also ich habe es mal ein bischen ausgebessert, aber das mit der Line ist noch nicht drin
Spoiler anzeigen
[autoit]#include <Misc.au3>
[/autoit] [autoit][/autoit] [autoit]
#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)while 1
[/autoit] [autoit][/autoit] [autoit]
$msg=GUIGetMsg()
Switch $msg
case -3
exit
case $label2
GUIDelete($main)
_neues()
EndSwitch
WEnd;Funktion _neues()
[/autoit] [autoit][/autoit] [autoit]
Func _neues()
$neues=GUICreate("",@desktopwidth,@desktopheight,-3,-29)
GUISetState(@sw_show)
$random=Random(50,1500,1)
$random2=Random(50,800,1)
AdlibEnable("_pressed",1000);GDIPlus für Elipse
[/autoit] [autoit][/autoit] [autoit]
_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;zeichnet Ellipse
[/autoit] [autoit][/autoit] [autoit]
$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();Funtion zum Beenden des Skripts
[/autoit]
Func _pressed()
if _IsPressed("1B") Then
exit
EndIf
EndFunc ;-> _pressed() -
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
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>
[/autoit] [autoit][/autoit] [autoit]
#include <GDIPlus.au3>HotKeySet("{ESC}", "_exit")
[/autoit] [autoit][/autoit] [autoit]
HotKeySet("{Left}", "_left")
HotKeySet("{right}", "_right")
HotKeySet("{up}", "_up")
HotKeySet("{down}", "_down")Global $faktorx = 7, $faktory = 0, $randomx = Random(50, 1500, 1), $randomy = Random(50, 800, 1), $buffer = ''
[/autoit] [autoit][/autoit] [autoit]
Dim $posarray[1]$main = GUICreate("", @DesktopWidth, @DesktopHeight, -3, -29)
[/autoit] [autoit][/autoit] [autoit]
GUISetBkColor(0x000000)$label = GUICtrlCreateLabel("Willkommen bei Snake", 500, 100, 430, 100)
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetColor(-1, 0x785463)
GUICtrlSetFont(-1, 30)$label2 = GUICtrlCreateLabel("Einzelspieler", 50, 300, @DesktopWidth, 100)
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetFont(-1, 20)
GUICtrlSetColor(-1, 0xFFD000)GUISetState(@SW_SHOW)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]
$graphic = _GDIPlus_GraphicsCreateFromHWND($main)While 1
[/autoit] [autoit][/autoit] [autoit]
$msg = GUIGetMsg()
Switch $msg
Case - 3
Exit
Case $label2
GUICtrlSetData($label, "")
GUICtrlDelete($label2)
GUISetBkColor(0xFFFFFF, $main)
AdlibEnable("_draw", 100)
EndSwitch
WEndFunc _draw()
[/autoit] [autoit][/autoit] [autoit]
$randomx += $faktorx
$randomy += $faktory_ArraySearch($posarray, $randomx & $randomy)
[/autoit] [autoit][/autoit] [autoit]
If Not @error Then _gameover()If $buffer <> $randomx & $randomy Then _
[/autoit] [autoit][/autoit] [autoit]
_ArrayAdd($posarray, $randomx & $randomy)If $randomx >= @DesktopWidth Then _gameover()
[/autoit] [autoit][/autoit] [autoit]
If $randomx <= 0 Then _gameover()
If $randomy >= @DesktopHeight Then _gameover()
If $randomy <= 0 Then _gameover()$buffer = $randomx & $randomy
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsFillEllipse($graphic, $randomx, $randomy, 14, 14)
[/autoit] [autoit][/autoit] [autoit]
EndFunc ;==>_drawFunc _exit()
[/autoit] [autoit][/autoit] [autoit]
;~ _GDIPlus_GraphicsDispose($graphic)
;~ _GDIPlus_Shutdown()
Exit
EndFunc ;==>_exitFunc _left()
[/autoit] [autoit][/autoit] [autoit]
If ($faktorx <> -7) And ($faktory <> 0) Then
$faktorx = -7
$faktory = 0
EndIf
EndFunc ;==>_leftFunc _up()
[/autoit] [autoit][/autoit] [autoit]
If ($faktorx <> 0) And ($faktory <> -7) Then
$faktorx = 0
$faktory = -7
EndIf
EndFunc ;==>_upFunc _down()
[/autoit] [autoit][/autoit] [autoit]
If ($faktorx <> 0) And ($faktory <> 7) Then
$faktorx = 0
$faktory = 7
EndIf
EndFunc ;==>_downFunc _right()
[/autoit] [autoit][/autoit] [autoit]
If ($faktorx <> 7) And ($faktory <> 0) Then
$faktorx = 7
$faktory = 0
EndIf
EndFunc ;==>_rightFunc _gameover()
[/autoit]
GUICtrlSetData($label, "Gameover")
AdlibDisable()
EndFunc ;==>_gameover -
anno2008
Ja so geht es gut, nur wenn man das Script so lässt wie er es gemacht hat nicht^^ -
sollte schon so bleiben
aber trotzdem danke
mfg Bio