Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GDIPlus.au3>
- #include <Array.au3>
- _GDIPlus_Startup()
- Global $Speed = 10
- Global $minLife = 500
- Global $maxLife = 2000
- Global $maxSpeed = 10.6
- Global $GUIWidth = 800
- Global $GUIHeight = 600
- Global $BackgroundColor = 0x40000000
- Global $PartN = InputBox("Numero particelle", "Inserisci il numero di particelle: ", 100)
- Global $FPS, $FPSTimer, $FPSCounter
- Dim $Particles[$PartN][9]
- For $i = 0 To $PartN - 1
- $Particles[$i][0] = $GUIWidth / 2
- $Particles[$i][1] = $GUIHeight / 2
- $Particles[$i][2] = Random(-$maxSpeed, $maxSpeed)
- $Particles[$i][3] = Random(-$maxSpeed, $maxSpeed)
- $Particles[$i][4] = 1
- $Particles[$i][5] = 1
- $Particles[$i][6] = 0xFF000000 + Random(0x0000FF, 0xFFFFFF, 1)
- $Particles[$i][7] = TimerInit()
- $Particles[$i][8] = Random($minLife, $maxLife, 1)
- Next
- Opt("GuiOnEventMode", 1)
- $GUI = GUICreate("asdParticles", $GUIWidth, $GUIHeight)
- GUISetBkColor(0x00000, $GUI)
- GUISetOnEvent(-3, "GUIExit")
- $Graphics = _GDIPlus_GraphicsCreateFromHWND($GUI)
- $BufferBMP = _GDIPlus_BitmapCreateFromGraphics($GUIWidth, $GUIHeight, $Graphics)
- $Buffer = _GDIPlus_ImageGetGraphicsContext($BufferBMP)
- _GDIPlus_GraphicsSetSmoothingMode($Buffer, 2)
- GUISetState(@SW_SHOW, $GUI)
- $FPSTimer = TimerInit()
- AdlibRegister("ShowFPS", 10)
- While 1
- _GDIPlus_GraphicsClear($Buffer, $BackgroundColor)
- $Brush = _GDIPlus_BrushCreateSolid()
- For $i = 0 To $PartN - 1
- $MousePos = GUIGetCursorInfo($GUI)
- If IsArray($MousePos) Then
- $distX = Abs($MousePos[0] - $Particles[$i][0])
- $distY = Abs($MousePos[1] - $Particles[$i][1])
- $distD = Sqrt($distX ^ 2 + $distY ^ 2)
- If $distD > 100 Then
- $Particles[$i][4] = Random(2,3,1)
- $Particles[$i][5] = Random(2,3,1)
- Else
- $Particles[$i][4] = Random(1,2,1)
- $Particles[$i][5] = Random(1,2,1)
- EndIf
- EndIf
- If $Particles[$i][7] > TimerInit() Then ContinueLoop
- If TimerDiff($Particles[$i][7]) > $Particles[$i][8] Then
- $Particles[$i][0] = $GUIWidth / 2
- $Particles[$i][1] = $GUIHeight / 2
- $Particles[$i][2] = Random(-$maxSpeed, $maxSpeed)
- $Particles[$i][3] = Random(-$maxSpeed, $maxSpeed)
- $Particles[$i][4] = 1
- $Particles[$i][5] = 1
- $Particles[$i][7] = TimerInit()+$maxLife*40
- $Particles[$i][8] = Random($minLife, $maxLife, 1)
- ContinueLoop
- EndIf
- _GDIPlus_BrushSetSolidColor($Brush, $Particles[$i][6])
- If ($Particles[$i][0] + $Particles[$i][2]) > $GUIWidth Then
- $Particles[$i][0] = $GUIWidth - ($Particles[$i][2] - ($GUIWidth - $Particles[$i][0]))
- $Particles[$i][2] *= -1
- ElseIf ($Particles[$i][0] + $Particles[$i][2]) < 0 Then
- $Particles[$i][0] = -($Particles[$i][2] + $Particles[$i][0])
- $Particles[$i][2] *= -1
- EndIf
- If ($Particles[$i][1] + $Particles[$i][3]) > $GUIHeight Then
- $Particles[$i][1] = $GUIHeight - ($Particles[$i][3] - ($GUIHeight - $Particles[$i][1]))
- $Particles[$i][3] *= -1
- ElseIf ($Particles[$i][1] + $Particles[$i][2]) < 0 Then
- $Particles[$i][1] = -($Particles[$i][2] + $Particles[$i][1])
- $Particles[$i][3] *= -1
- EndIf
- $Particles[$i][2] *= 0.98
- $Particles[$i][3] *= 0.98
- $Particles[$i][0] += $Particles[$i][2]
- $Particles[$i][1] += $Particles[$i][3]
- _GDIPlus_GraphicsFillEllipse($Buffer, $Particles[$i][0], $Particles[$i][1], $Particles[$i][4], $Particles[$i][5], $Brush)
- Next
- _GDIPlus_GraphicsDrawImageRect($Graphics, $BufferBMP, 0, 0, $GUIWidth, $GUIHeight)
- FPSCounter()
- Sleep(20)
- WEnd
- Func GUIExit()
- _GDIPlus_Shutdown()
- Exit
- EndFunc
- Func FPSCounter()
- If TimerDiff($FPSTimer) > 1000 Then
- $FPSTimer = TimerInit()
- $FPS = $FPSCounter
- $FPSCounter = 0
- EndIf
- $FPSCounter += 1
- EndFunc
- Func ShowFPS()
- ToolTip($FPS&" fps")
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement