Code: Alles auswählen
InitSprite()
InitKeyboard()
InitMouse()
W.l = 1280 ;Screen-Breite
H.l = 1024 ;Screen-Höhe
If OpenScreen(W,H,32,"Vulkan Partikelstrahlen") = 0
End
EndIf
Structure dat ;Partikeldaten-Structur
x.f
y.f
oldx.l
oldy.l
xm.f
ym.f
c.w
EndStructure
NewList p.dat() ;Partikelliste erstellen
Repeat
ExamineKeyboard()
ExamineMouse()
ClearScreen(0)
If MouseButton(1)
For x = 1 To 5 ;Gleich 5 auf einmal für mehr Volumen
AddElement(p()) ;Neuen Partikel erstellen
;Startposition an Maus:
p()\x = MouseX()
p()\y = MouseY()
p()\oldx = MouseX()
p()\oldy = MouseY()
;Startgeschwindigkeit zufällig:
p()\xm = (Random(200)-100)/100
p()\ym = -(Random(300)/100)-4
;Zur Quradratbildungsvermeindung:
p()\ym + Abs(p()\xm)-1
;Start-Farbe:
p()\c = 511
Next
EndIf
If MouseButton(2)
ClearList(p()) ;Alle Partikel löschen
EndIf
StartDrawing(ScreenOutput())
ForEach p()
;Alte Werte merken
oldx = p()\x
oldy = p()\y
;Partikelbewegung
p()\ym + 0.05 ;Geschwindigkeit nach unten nimmt zu
p()\x + p()\xm ;X-Position wird geändert
p()\y + p()\ym ;Y-Position wird geändert
p()\c - 2 ;Farbe wird dunkler
If p()\c < 0 Or p()\y > H+10 Or p()\x < -10 Or p()\x > W+10 ;Wenn Schwarz oder außerhalb des Bildschirms
DeleteElement(p()) ;Partikel kann weg
Else
;Farbe bestimmen:
If p()\c > 256 ;Gelb nach Rot
color = RGB(255,p()\c-256,0)
Else ;Rot nach Schwarz
color = RGB(p()\c,0,0)
EndIf
;Dunkler für den alten Teil:
If p()\c-20 > 256 ;Gelb nach Rot
darkcolor = RGB(255,p()\c-256-20,0)
ElseIf p()\c-20 > 0 ;Rot nach Schwarz
darkcolor = RGB(p()\c-20,0,0)
Else
darkcolor = 0
EndIf
;Beide Teile Zeichnen:
LineXY(oldx,oldy,p()\oldx,p()\oldy,darkcolor) ;Alten Teil nochmal zeichnen
LineXY(p()\x,p()\y,oldx,oldy,color) ;Neuen Teil zeichnen
;Alte Werte eintragen:
p()\oldx = oldx
p()\oldy = oldy
EndIf
Next
Circle(MouseX(),MouseY(),4,RGB(255,255,128)) ;Maus Zeichnen
StopDrawing()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
CloseScreen()
End