Author Topic: Cool fireworks  (Read 215 times)

cvirus

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Cool fireworks
« on: July 15, 2014 »
Some old code but a cool efect, with the help of the Creator :-)

Code: [Select]
set window 32, 32, 320, 240, false, 2
set redraw off

x#=160.0
y#=120.0
rem Array for the dots.
dots#[64][5]

for i = 0 to 63
rem All dots start at position 160, 120.
dots[i][0] = x
dots[i][1] = y
rem Create a random angle, and set the direction of the dot
rem to (cos(angle)  sin(angle)).
angle# = float(rnd(360))
dots[i][2] = cos(angle)
dots[i][3] = sin(angle)
rem Set speed of dot to something in the range [0.25 .. 3.0]
dots[i][4] = float(25 + rnd(275))/100.0
next

wait 500

do
set color 0, 0, 0
cls
set color rnd(255), rnd(255), rnd(255)
rem Update and draw dots.
for i = 0 to 63
rem Dot is only active if its speed is greater than 0.0.
if dots[i][4] > 0.0
rem Move dot in its direction with its speed.
dots[i][0] = dots[i][0] + dots[i][2]*dots[i][4]
dots[i][1] = dots[i][1] + dots[i][3]*dots[i][4]
rem Decrease speed.
dots[i][4] = dots[i][4] - 0.04
rem Draw.
draw pixel int(dots[i][0]), int(dots[i][1])
endif
next
redraw
  wait 10


johnno56

  • Guest
Re: Cool fireworks
« Reply #1 on: July 15, 2014 »
Minor error with the "do" loop, but after fixing, ran like a charm. Very cool effect.

J