Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New Years Eve Fireworks!
#18
Better?

Can perfection be improved? mayb+ Smile
Code: (Select All)
'Fireworks 3 by SierraKen mod b+ 2024-12-29 Ken inspires me too!
'Firework sound from https://pixabay.com/sound-effects/search/fireworks/

'Thanks B+ for the inspiration.

Screen _NewImage(800, 600, 32)
Dim x(200), y(200), xx(200), yy(200)
Dim centerx(200), centery(200)
Dim c(200) As _Unsigned Long  ' <<< best Type for RGB colors

_Title "Fireworks"

file$ = "firework_single.mp3"
file2$ = "firework_single_small.mp3"
Song = _SndOpen(file$)
song2 = _SndOpen(file2$)
If Song < 1 Or song2 < 1 Then '  <<< for some reason not getting 2nd sound, oh my mistake later maybe make sure both loaded here
    Print "Failed to load a sound file!"
    End
End If

GoSub more

Randomize Timer
Do
    ce = ce + 1
    If ce > 200 Then ce = 1
    centerx(ce) = (Rnd * 400) + 200
    centery(ce) = (Rnd * 100) + 300
    red = (Rnd * 200) + 55: green = (Rnd * 200) + 55: blue = (Rnd * 200) + 55

    ' vvvv why?  <<<<
    'If red > green And red > blue And red < 200 Then red = 255
    'If green > red And green > blue And green < 200 Then green = 255
    'If blue > red And blue > green And blue < 200 Then blue = 255
    'If blue < 150 Then blue = 255
    'If green < 150 Then green = 255
    'If red < 150 Then red = 255

    c(ce) = _RGB32(red, green, blue)

    If booms < 11 Then _SndPlay Song Else _SndPlay song2
    'If booms > 10 Then _SndPlay song2 ' <<< combine lines above
    If booms < 11 Then GoSub trajectile

    For b = 1 To 300
        For e = 1 To 200
            x(e) = x(e) + xx(e)
            y(e) = y(e) + yy(e)
            cx = x(e) + centerx(ce)
            cy = y(e) + centery(ce)
            fillCircle cx, cy, 2, c(ce)
        Next e
        If booms < 11 Then _Limit (300 - b) + 60  ' <<< here I slow blast down as airs out
        'If booms < 30 Then _Delay .005  ' <<< see above
        'If booms > 29 Then _Limit 500  ' <<< see above
        Line (0, 0)-(800, 600), _RGB32(0, 0, 0, 10), BF
    Next b
    t = 1
    GoSub more

    booms = booms + 1
    _Title "Fireworks Boom:" + Str$(booms)  ' <<< to watch count to 10 not previous 40? Ken had
    If booms = 10 Then
        _SndStop Song
    End If
    If booms = 20 Then
        _SndStop song2
        Cls
        End
    End If

Loop Until InKey$ = Chr$(27)
End

more:
For t = 1 To 200
    r = Rnd * 2 '  <<< from 4 to 2 to contain spread a little more??
    a = Rnd * _Pi(2) ' <<<< (2) = pi times 2, does whole circle not half so angle is from 0 to 360 in degrees equivalent
    x(t) = r * Cos(a)
    y(t) = r * Sin(a)
    'If t < 50 Then xx(t) = r * Cos(a)
    'If t < 50 Then xx(t) = r * Cos(a) ' <<< this is error !!! , never mind I must of screwed up this line??? It's good in Ken's zip
    'If t > 49 Then xx(t) = r * -Cos(a)
    'If t > 49 Then yy(t) = r * -Sin(a)
    xx(t) = r * Cos(a): yy(t) = r * Sin(a) '<<<  (2) does whole circle not half
Next t
Return

trajectile:
For ty = 600 To centery(ce) Step -1
    fillCircle centerx(ce), ty, 2, _RGB32(255, 255, 255)
    _Delay .002
    Line (0, 0)-(800, 600), _RGB32(0, 0, 0, 10), BF
Next ty
Return

'from Steve Gold standard
Sub fillCircle (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
    Dim Radius As Integer, RadiusError As Integer
    Dim X As Integer, Y As Integer
    Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
    If Radius = 0 Then PSet (CX, CY), C: Exit Sub
    Line (CX - X, CY)-(CX + X, CY), C, BF
    While X > Y
        RadiusError = RadiusError + Y * 2 + 1
        If RadiusError >= 0 Then
            If X <> Y + 1 Then
                Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
    Wend
End Sub

note: my changes marked with ' <<<
b = b + ...
Reply


Messages In This Thread
New Years Eve Fireworks! - by SierraKen - 12-28-2024, 01:45 AM
RE: New Years Eve Fireworks! - by bplus - 12-28-2024, 02:59 AM
RE: New Years Eve Fireworks! - by eoredson - 12-28-2024, 04:58 AM
RE: New Years Eve Fireworks! - by SierraKen - 12-28-2024, 05:57 AM
RE: New Years Eve Fireworks! - by SierraKen - 12-28-2024, 07:28 AM
RE: New Years Eve Fireworks! - by DANILIN - 12-28-2024, 09:35 AM
RE: New Years Eve Fireworks! - by SierraKen - 12-28-2024, 05:39 PM
RE: New Years Eve Fireworks! - by bplus - 12-28-2024, 07:34 PM
RE: New Years Eve Fireworks! - by SierraKen - 12-28-2024, 10:18 PM
RE: New Years Eve Fireworks! - by bplus - 12-28-2024, 10:46 PM
RE: New Years Eve Fireworks! - by SierraKen - 12-28-2024, 11:07 PM
RE: New Years Eve Fireworks! - by SierraKen - 12-28-2024, 11:54 PM
RE: New Years Eve Fireworks! - by SierraKen - 12-29-2024, 12:40 AM
RE: New Years Eve Fireworks! - by James D Jarvis - 12-29-2024, 01:22 AM
RE: New Years Eve Fireworks! - by bplus - 12-29-2024, 01:24 AM
RE: New Years Eve Fireworks! - by SierraKen - 12-29-2024, 01:29 AM
RE: New Years Eve Fireworks! - by SierraKen - 12-29-2024, 05:13 PM
RE: New Years Eve Fireworks! - by bplus - 12-29-2024, 07:18 PM
RE: New Years Eve Fireworks! - by SierraKen - 12-29-2024, 08:46 PM
RE: New Years Eve Fireworks! - by bplus - 12-29-2024, 09:42 PM
RE: New Years Eve Fireworks! - by SierraKen - 12-29-2024, 10:36 PM
RE: New Years Eve Fireworks! - by bplus - 12-29-2024, 11:12 PM
RE: New Years Eve Fireworks! - by SierraKen - 12-29-2024, 11:49 PM
RE: New Years Eve Fireworks! - by SierraKen - 12-30-2024, 06:22 PM
RE: New Years Eve Fireworks! - by bplus - 12-31-2024, 01:23 PM
RE: New Years Eve Fireworks! - by SierraKen - 12-31-2024, 05:13 PM
RE: New Years Eve Fireworks! - by bplus - 12-31-2024, 06:57 PM
RE: New Years Eve Fireworks! - by SMcNeill - 12-31-2024, 08:20 PM
RE: New Years Eve Fireworks! - by SierraKen - 12-31-2024, 09:23 PM
RE: New Years Eve Fireworks! - by bplus - 12-31-2024, 10:23 PM
RE: New Years Eve Fireworks! - by SierraKen - 12-31-2024, 10:29 PM
RE: New Years Eve Fireworks! - by bplus - 01-01-2025, 04:01 AM
RE: New Years Eve Fireworks! - by SierraKen - 01-01-2025, 05:17 AM
RE: New Years Eve Fireworks! - by bplus - 01-01-2025, 06:23 AM



Users browsing this thread: 20 Guest(s)