I wrote this while looking for a fireworks simulator thing. It can be modified very easily to let the user place the fireworks wherever they want.
I thought that it was good enough to post on the forum.
TheTeapot
Code: Select all
;;;;;;;;;TheTeapot's FireWorks Thingy;;;;;;;;;;;;;;;;
Structure shl
x.l
y.l
vY.l
str.l
clr.l
stp.l
EndStructure
Structure dot
x.f
y.f
angle.l
speed.f
g.f
clr.l
EndStructure
NewList Shell.shl()
NewList Proj.dot()
InitSprite()
InitKeyboard()
InitMouse()
If OpenScreen(1024, 768, 32, "FireWorks") = 0
MessageRequester("FireWorks", "Direct X not initialised.")
EndIf
ChangeGamma(0, 0, 0)
SetFrameRate(24)
Repeat
ExamineKeyboard()
ExamineMouse()
ClearScreen(RGB(0, 0, 0))
If Bias = 1 ; Red
R = Random(128) + 128
G = Random(128)
B = Random(128)
ElseIf Bias = 2 ; Green
R = Random(128)
G = Random(128) + 128
B = Random(128)
ElseIf Bias = 3 ; Blue
R = Random(128)
G = Random(128)
B = Random(128) + 128
EndIf
Bias = Random(2) + 1
If Random(40) = 1
AddElement(Shell())
Shell()\x = Random(1024);MouseX()
Shell()\y = 768
Shell()\vY = 4
Shell()\str = 5 * 360
Shell()\clr = RGB(R, G, B)
Shell()\stp = Random(768)
EndIf
ForEach Shell()
If Shell()\stp > Shell()\y
For pCount = 1 To Shell()\str
AddElement(Proj())
Proj()\x = Shell()\x
Proj()\y = Shell()\y
Proj()\angle = pCount
Proj()\speed = (Random(20) + 20) / Random(40)
Proj()\clr = Shell()\clr
Proj()\g = 1.1
Next
DeleteElement(Shell(), 1)
EndIf
Next
StartDrawing(ScreenOutput())
;Circle(MouseX(), MouseY(), 1, RGB(255, 128, 128))
ForEach Shell()
Circle(Shell()\x, Shell()\y, 2, RGB(255,255,255))
Shell()\y = Shell()\y - Shell()\vY
If Shell()\y <= 1
DeleteElement(Shell())
EndIf
Next
ForEach Proj()
angle = Proj()\angle
Proj()\x = Proj()\x + (Cos(angle * 3.141592/180) * Proj()\speed)
Proj()\y = Proj()\y + (Sin(angle * 3.141592/180) * Proj()\speed) + Proj()\g
Proj()\g = Proj()\g + 0.1
Proj()\speed = Proj()\speed + 0.001
clr = Proj()\clr
cR = Red(clr)
cG = Green(clr)
cB = Blue(clr)
If cR > cG And cR > cB
; cR = cR - 1
cG = cG + 1
cB = cB + 1
ElseIf cG > cR And cG > cB
cR = cR + 1
; cG = cG - 1
cB = cB + 1
ElseIf cB > cR And cB > cG
cR = cR + 1
cG = cG + 1
; cB = cB - 1
EndIf
Proj()\clr = RGB(cR, cG, cB)
If Proj()\x >= 1023 Or Proj()\x <= 0 Or Proj()\y >= 767 Or Proj()\y <= 0
DeleteElement(Proj(), 1)
Else
Plot(Proj()\x, Proj()\y, Proj()\clr)
EndIf
Next
StopDrawing()
FlipBuffers()
framecount + 1
Delay(1)
Until KeyboardReleased(#PB_Key_Escape);MouseDeltaX() <> 0 Or MouseDeltaY() <> 0 Or KeyboardPushed(#PB_Key_All)