Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fireworks
#1
Happy new year, a bit late!

Code:
#win32
set window "2025", 640, 480
set redraw off
particles = []; t = 60
while not keydown(KEY_ESCAPE, true)
    t = t - 1
    if t <= 0
        particles[sizeof(particles)] = Firework(true, particles,
                rnd(width(primary)), height(primary))
        t = 30 + rnd(4)*30
    endif
    i = 0
    while i < sizeof(particles)
        if particles[i].Update()  i = i + 1
        else  free key particles, i
    wend
    set color 0, 0, 0, 16; cls
    foreach p in particles  p.Draw()
    redraw
    fwait 60
wend

function Firework(goingUp, list, x, y)
    if goingUp  a = 225 + rnd(90)
    else  a = rnd(360)
    p = [
        goingUp: goingUp, list: list,
        x: x, y: y,
        dx: cos(rad(a)), dy: sin(rad(a)),
        r: 128 + rnd(128), g: 128 + rnd(128), b: 128 + rnd(128), a: 255, spd: 0.5 + rnd()*0.5,
        Update: function()
            if .goingUp
                .x = .x + .dx*0.5; .y = .y + .dy*4; .dy = .dy + 0.005
                if .dy >= 0.25
                    for i = 1 to 100
                        .list[sizeof(.list)] = Firework(false, .list, .x, .y)
                    next
                    return false
                else
                    return true
                endif
            else
                .x = .x + .dx*.spd; .y = .y + .dy*.spd; .dy = .dy + 0.005
                .a = .a - 1.5*.spd
                return .a > 0
            endif
        endfunc,
        Draw: function()
            set color .r, .g, .b, .a
            draw pixel .x, .y
        endfunc]
    return p
endfunc

Some sound effects would be nice ...
Reply
#2
No. Never too late for an excellent firework display!! Well done!!

Found this sound file on OpenGameArt.org. The site user is "Rubberduck"

https://opengameart.org/content/25-cc0-b...rework-sfx

Converted the fw_loop.ogg to .wav


.zip   fw_loop.wav.zip (Size: 1.75 MB / Downloads: 2)

Hope this is ok...

J
Logic is the beginning of wisdom.
Reply
#3
The fireworks were so amazing, I’m pretty sure NASA called to ask who launched them!
They were so spectacular,  even the stars were jealous and took a coffee break!

Big Grin
Reply
#4
Mmmm... Coffee...
Logic is the beginning of wisdom.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)