GDI+ Partikelexplosion (noch eine ;-) )

  • So, da es ja auch schon einige Partikelexplosionen in GDI+ gibt, hab ich jetzt auch mal eine gemacht :D
    Allerdings finde ich, dass meine nicht ganz so gut ist, wie die anderen.

    Hier das Skript:

    Spoiler anzeigen
    [autoit]


    #include <GDIPlus.au3>
    #include <GUIConstants.au3>
    #include <Color.au3>

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

    Opt("GuiOnEventMode", 1)

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

    Global $iGUIHeight = 800
    Global $iGUIWidth = 800
    Global $iX = 400
    Global $iY = 400
    Global $AmountParticles = 70 ;;##Anzahl der Partikel
    Global $ParticlesPos[$AmountParticles][2]
    Global $ParticlesWay[$AmountParticles][2]
    Global $DurchlaufZahl = -1.5
    Global $Hex = 255
    Global $Color = _RandomColor()

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

    For $i = 0 To $AmountParticles - 1
    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][0] = Random(1, 100, 1) / 50
    EndIf

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

    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][1] = Random(1, 100, 1) / 50
    EndIf
    Next

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

    For $i = 0 To $AmountParticles - 1
    $ParticlesPos[$i][0] = ($iX - $ParticlesWay[$i][0])
    $ParticlesPos[$i][1] = ($iY + $ParticlesWay[$i][1])
    Next

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

    Global $hGUI = GUICreate("Partikelexplosion by ClezZ", $iGUIWidth, $iGUIHeight)
    GUISetState()

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

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

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

    _GDIPlus_Startup()

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

    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphics)
    Global $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
    _GDIPlus_GraphicsClear($hBuffer, 0xFF000000)
    Global $hBrush = _GDIPlus_BrushCreateSolid('0xFF' & $Color)

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

    _WM_PAINT()

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

    AdlibRegister("_ParticleDraw", 19)

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

    While 1
    WEnd

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

    Func _ParticleDraw()
    _GDIPlus_GraphicsClear($hBuffer, '0x'&Hex(50, 2)&'000000')

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

    For $i = 0 To $AmountParticles - 1
    $ParticlesPos[$i][0] += $ParticlesWay[$i][0] / $DurchlaufZahl
    $ParticlesPos[$i][1] += $ParticlesWay[$i][1] / $DurchlaufZahl
    _GDIPlus_GraphicsFillEllipse($hBuffer, $ParticlesPos[$i][0], $ParticlesPos[$i][1], 4, 4, $hBrush)
    Next

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

    $Hex += $DurchlaufZahl
    _GDIPlus_BrushSetSolidColor($hBrush, '0x' & Hex($Hex, 2) & $Color)

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

    If $Hex <= 0 Then
    _GDIPlus_GraphicsClear($hBuffer, '0xFF000000')
    For $i = 0 To $AmountParticles - 1
    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][0] = Random(1, 100, 1) / 50
    EndIf

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

    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][1] = Random(1, 100, 1) / 50
    EndIf
    Next

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

    $iX = Random(100, $iGUIWidth-100, 1)
    $iY = Random(100, $iGUIHeight-100, 1)
    For $i = 0 To $AmountParticles - 1
    $ParticlesPos[$i][0] = $iX
    $ParticlesPos[$i][1] = $iY
    Next

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

    $DurchlaufZahl = -1.5
    $Hex = 255
    $Color = _RandomColor()
    EndIf

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

    $DurchlaufZahl -= 0.01

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

    _WM_PAINT()
    EndFunc ;==>_ParticleDraw

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

    Func _Exit()
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

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

    Func _WM_PAINT()
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
    EndFunc ;==>_WM_PAINT

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

    Func _RandomColor()
    Local $BackColor[3]
    $BackColor[0] = Random(70, 255, 1)
    $BackColor[1] = Random(70, 255, 1)
    $BackColor[2] = Random(70, 255, 1)
    Return Hex(_ColorSetRGB($BackColor), 6)
    EndFunc ;==>_RandomColor

    [/autoit]

    Und hier noch, mit Hilfe von name22, als Screensaver:

    Spoiler anzeigen
    [autoit]


    #include <GDIPlus.au3>
    #include <GUIConstants.au3>
    #include <WindowsConstants.au3>
    #include <Color.au3>
    #include <Timers.au3>

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

    Opt("GuiOnEventMode", 1)

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

    Global $iGUIHeight = 500
    Global $iGUIWidth = 500
    Global $iX = 200
    Global $iY = 200
    Global $AmountParticles = 60
    Global $ParticlesPos[$AmountParticles][2]
    Global $ParticlesWay[$AmountParticles][2]
    Global $DurchlaufZahl = -1.5
    Global $Hex = 255
    Global $Color = _RandomColor()

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

    For $i = 0 To $AmountParticles - 1
    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][0] = Random(1, 100, 1) / 50
    EndIf

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

    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][1] = Random(1, 100, 1) / 50
    EndIf
    Next

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

    For $i = 0 To $AmountParticles - 1
    $ParticlesPos[$i][0] = ($iX - $ParticlesWay[$i][0])
    $ParticlesPos[$i][1] = ($iY + $ParticlesWay[$i][1])
    Next

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

    Global $hGUI = GUICreate("Partikelexplosion by ClezZ", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
    WinSetState($hGUI, "", @SW_MAXIMIZE)
    GUISetCursor(16, 1, $hGUI)
    GUISetState()

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

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

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

    _GDIPlus_Startup()

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

    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphics)
    Global $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
    _GDIPlus_GraphicsClear($hBuffer, 0xFF000000)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)
    Global $hBrush = _GDIPlus_BrushCreateSolid('0xFF' & $Color)

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

    Sleep(100)

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

    While Sleep(20)
    If _Timer_GetIdleTime() <= 100 Then _Exit()

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

    _GDIPlus_GraphicsClear($hBuffer, '0x'&Hex(50, 2)&'000000')

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

    For $i = 0 To $AmountParticles - 1
    $ParticlesPos[$i][0] += $ParticlesWay[$i][0] / $DurchlaufZahl
    $ParticlesPos[$i][1] += $ParticlesWay[$i][1] / $DurchlaufZahl
    _GDIPlus_GraphicsFillEllipse($hBuffer, $ParticlesPos[$i][0], $ParticlesPos[$i][1], 4, 4, $hBrush)
    Next

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

    $Hex += $DurchlaufZahl
    _GDIPlus_BrushSetSolidColor($hBrush, '0x' & Hex($Hex, 2) & $Color)

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

    If $Hex <= 0 Then
    _GDIPlus_GraphicsClear($hBuffer, '0xFF000000')
    For $i = 0 To $AmountParticles - 1
    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][0] = Random(1, 100, 1) / 50
    EndIf

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

    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][1] = Random(1, 100, 1) / 50
    EndIf
    Next

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

    $iX = Random(100, $iGUIWidth-100, 1)
    $iY = Random(100, $iGUIHeight-100, 1)
    For $i = 0 To $AmountParticles - 1
    $ParticlesPos[$i][0] = $iX
    $ParticlesPos[$i][1] = $iY
    Next

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

    $DurchlaufZahl = -1.5
    $Hex = 255
    $Color = _RandomColor()
    EndIf

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

    $DurchlaufZahl -= 0.01

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

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, @DesktopWidth / 2 - $iGUIWidth / 2, @DesktopHeight / 2 - $iGUIHeight / 2, $iGUIWidth, $iGUIHeight)
    WEnd

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

    Func _Exit()
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

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

    Func _RandomColor()
    Local $BackColor[3]
    $BackColor[0] = Random(70, 255, 1)
    $BackColor[1] = Random(70, 255, 1)
    $BackColor[2] = Random(70, 255, 1)
    Return Hex(_ColorSetRGB($BackColor), 6)
    EndFunc ;==>_RandomColor

    [/autoit]

    //Edit: Dann noch die "XP Version", für die, bei denen es ruckelt ;)

    Spoiler anzeigen
    [autoit]


    #include <GDIPlus.au3>
    #include <GUIConstants.au3>
    #include <Color.au3>

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

    Opt("GuiOnEventMode", 1)

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

    Global $iGUIHeight = 800
    Global $iGUIWidth = 800
    Global $iX = 400
    Global $iY = 400
    Global $AmountParticles = 40
    Global $ParticlesPos[$AmountParticles][2]
    Global $ParticlesWay[$AmountParticles][2]
    Global $DurchlaufZahl = -1.5
    Global $Hex = 255
    Global $Color = _RandomColor()

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

    For $i = 0 To $AmountParticles - 1
    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][0] = Random(1, 100, 1) / 50
    EndIf

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

    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][1] = Random(1, 100, 1) / 50
    EndIf
    Next

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

    For $i = 0 To $AmountParticles - 1
    $ParticlesPos[$i][0] = ($iX - $ParticlesWay[$i][0])
    $ParticlesPos[$i][1] = ($iY + $ParticlesWay[$i][1])
    Next

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

    Global $hGUI = GUICreate("Partikelexplosion by ClezZ", $iGUIWidth, $iGUIHeight)
    GUISetState()
    WinSetTrans($hGUI,"",0xFF)

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

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

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

    _GDIPlus_Startup()

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

    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphics)
    Global $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
    _GDIPlus_GraphicsClear($hBuffer, 0xFF000000)
    Global $hBrush = _GDIPlus_BrushCreateSolid('0xFF' & $Color)

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

    _WM_PAINT()

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

    AdlibRegister("_ParticleDraw", 19)

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

    While 1
    WEnd

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

    Func _ParticleDraw()
    _GDIPlus_GraphicsClear($hBuffer, '0x'&Hex(50, 2)&'000000')

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

    For $i = 0 To $AmountParticles - 1
    $ParticlesPos[$i][0] += $ParticlesWay[$i][0] / $DurchlaufZahl
    $ParticlesPos[$i][1] += $ParticlesWay[$i][1] / $DurchlaufZahl
    _GDIPlus_GraphicsFillEllipse($hBuffer, $ParticlesPos[$i][0], $ParticlesPos[$i][1], 4, 4, $hBrush)
    Next

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

    $Hex += $DurchlaufZahl
    _GDIPlus_BrushSetSolidColor($hBrush, '0x' & Hex($Hex, 2) & $Color)

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

    If $Hex <= 0 Then
    _GDIPlus_GraphicsClear($hBuffer, '0xFF000000')
    For $i = 0 To $AmountParticles - 1
    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][0] = Random(1, 100, 1) / 50
    EndIf

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

    $Random = Random(1, 2, 1)
    If $Random = 1 Then
    $ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
    Else
    $ParticlesWay[$i][1] = Random(1, 100, 1) / 50
    EndIf
    Next

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

    $iX = Random(100, $iGUIWidth-100, 1)
    $iY = Random(100, $iGUIHeight-100, 1)
    For $i = 0 To $AmountParticles - 1
    $ParticlesPos[$i][0] = $iX
    $ParticlesPos[$i][1] = $iY
    Next

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

    $DurchlaufZahl = -1.5
    $Hex = 255
    $Color = _RandomColor()
    EndIf

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

    $DurchlaufZahl -= 0.01

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

    _WM_PAINT()
    EndFunc ;==>_ParticleDraw

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

    Func _Exit()
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

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

    Func _WM_PAINT()
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
    EndFunc ;==>_WM_PAINT

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

    Func _RandomColor()
    Local $BackColor[3]
    $BackColor[0] = Random(70, 255, 1)
    $BackColor[1] = Random(70, 255, 1)
    $BackColor[2] = Random(70, 255, 1)
    Return Hex(_ColorSetRGB($BackColor), 6)
    EndFunc ;==>_RandomColor

    [/autoit]
  • sehr schon. Wenn man die Durchlaufzahl statt -1,5 auf 1,5 setzt siehts sichtig geil aus ;)

    Das finden von Rechtschreibfehlern muss sofort und unverzüglich dem Autor gemeldet werden. Das eigennützige Verwenden dieser Rechtschreibfehler ist strengstens untersagt und kann mit Freiheitsenzug bestraft werden.

  • neh es gibt schon mehrere nur die abstände indenen sie komen werden natürlich größer

    Das finden von Rechtschreibfehlern muss sofort und unverzüglich dem Autor gemeldet werden. Das eigennützige Verwenden dieser Rechtschreibfehler ist strengstens untersagt und kann mit Freiheitsenzug bestraft werden.

  • Eine Exe in SCR umbenennen macht daraus nicht umbedingt einen richtigen Screensaver - das ist ein wenig komplizierter ;)

    Anonsonsten sieht es gut aus :thumbup:

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Bei mir ruckelt das wie Sau...
    Mach aber keinen Sinn, denn ich hab eigentlich einen sehr schnellen PC (http://www.sysprofile.de/id132999)

    Edit: Ah, hab gerade WinXP am, laufen, und als ich Eukalyptus Trick ausprobiert hatte gings sehr schnell (3000 war noch flüssig)

    Spoiler anzeigen

    Grundkenntnisse in: C++, JavaScript
    Sehr gute Kenntnisse: PHP, JAVA, C und näturlich AutoIt


    Klaviatur, Anhang UDF, GDI+ Mühle

    Zitat

    "Wenn einen um 20h der Pizzadienst anruft und fragt, ob man's nur vergessen hat und ob man das gleiche
    möchte wie immer -- dann sollte man sein Bestellverhalten evtl überdenken"

  • sehr schön ich habs mit 1500 partikeln getestet und dan fings bisle an :thumbup:
    clezZ ist es auch möglich sowas wie kluster partikel zu machen? also die erste explosion kommt und nach na halben sekunde explodieren die und daraus kommen dan noch mehr partikel
    das wäre bestimmt auch ein schöner effekt
    mfg bulli