_Title "Happy Trails 2022" 'from Happy Trails 2018 ' 2017-12-29 another redesign of fireworks
' 2017-12-28 redesign fireworks
' now with lake refelction 2017-12-27 forget the bouncing sparks
' combine Welcome Plasma Font with landscape
'_title "Fireworks 3 translation to QB64 2017-12-26 bplus"
'fireworks 3.bas SmallBASIC 0.12.2 [B+=MGA] 2015-05-09
'fireworks 2.bas 2016-05-05 now with Gravity, Newtonian bounce, smoke debris
'fireworks 3.bas try with map variables make bursts around a central point
Const waterline
= 600 ' 600 = ratio 5 to 1 sky to water ' raise and lower waterline as desired highest about 400?
Const bluey
= 5 * 256 ^ 2 + 256 * 5 + 5
'prepare message font
mess$ = " Happy New Year 2022"
w
= 8 * Len(mess$
): h
= 16 p(x, y) = 1
xo = 0: yo = 15: m = 7.2
resetPlasma
'prepare landscape
drawLandscape
'prepare fire works
nFW = 3
initFireWork (i)
''debris feild
'DIM debris(debrisMax) AS debrisType
'OK start the show
'cls screen with land image
'draw fireworks
If fw
(f
).age
<= fw
(f
).life
Then drawfw
(f
) Else initFireWork f
''debris
'FOR i = 0 TO debrisStack
' PSET (debris(i).x, debris(i).y), debris(i).c
' debris(i).x = debris(i).x + RND * 3 - 1.5
' debris(i).y = debris(i).y + RND * 3.5 - 1.5
' IF debris(i).x < 0 OR debris(i).y < 0 OR debris(i).x > xmax OR debris(i).y > waterline + RND * 20 THEN NewDebris (i)
'NEXT
'text message in plasma
changePlasma
Line (xo
+ x
* m
, yo
+ y
* m
)-(xo
+ x
* m
+ m
, yo
+ y
* m
+ m
), , BF
lc = lc + 1
'reflect sky
skyWaterRatio = waterline / (ymax - waterline) - .05
For y
= waterline
To ymax
c&&
= Point(x
, waterline
- ((y
- waterline
- 1) * skyWaterRatio
) + Rnd * 5) PSet (x
, y
+ 1), c&&
+ bluey
_Limit 200 'no limit needed on my system!
''accumulate debris
'IF lc MOD 2000 THEN
' IF debrisStack < debrisMax THEN
' FOR i = 1 TO 2
' NewDebris i + debrisStack
' NEXT
' debrisStack = debrisStack + 2
' END IF
'END IF
'SUB NewDebris (i)
' debris(i).x = RND * xmax
' debris(i).y = RND * ymax
' c = RND * 155
' debris(i).c = _RGB32(c, c, c)
'END SUB
cN = cN + .01
Color _RGB(127 + 127 * Sin(pR!
* .3 * cN
), 127 + 127 * Sin(pG!
* .3 * cN
), 127 + 127 * Sin(pB!
* .3 * cN
))
'the sky
midInk 0, 0, 0, 78, 28, 68, i / ymax
'the land
startH = waterline - 80
rr = 10: gg = 20: bb = 15
Xright = 0
y = startH
' upDown = local up / down over range, change along Y
' range = how far up / down, along X
upDown
= (Rnd * .8 - .35) * (1 / (1 * mountain
)) range = Xright + rand&&(5, 35) * 2.5 / mountain
lastx = Xright - 1
y = y + upDown
Line (lastx
, y
)-(X
, ymax
), , BF
'just lines weren't filling right lastx = X
Xright = range
rr = rand&&(rr + 5, rr): gg = rand&&(gg + 5, gg): bb = rand&&(bb + 4, bb)
startH = startH + rand&&(1, 10)
'LINE (0, waterline)-(xmax, ymax), _RGB32(0, 0, 0), BF
Sub midInk
(r1
, g1
, b1
, r2
, g2
, b2
, fr
) Color _RGB(r1
+ (r2
- r1
) * fr
, g1
+ (g2
- g1
) * fr
, b1
+ (b2
- b1
) * fr
)
rand&&
= Int(Rnd * (hi&&
- lo&&
+ 1)) + lo&&
'here's how to "save" a bunch of random numbers without data and arrays but tons of redundant calculations
Randomize Using fw
(i
).seed
'this repeats all random numbers generated by seed in same sequence 'recreate our firework from scratch!
red = rand&&(200, 255)
green = rand&&(200, 255)
blue = rand&&(200, 255)
x = rand&&(1, 4)
red = 0
green = 0
blue = 0
x = rand&&(1, 4)
red = 0: green = 0
green = 0: blue = 0
blue = 0: red = 0
ne = rand&&(80, 300)
embers
(e
, 0) = r
* Cos(e
* _Pi(2) / 101) embers
(e
, 1) = r
* Sin(e
* _Pi(2) / 101) start = fw(i).age - lTail ' don't let tails get longer than lTail const
cx = fw(i).x: cy = fw(i).y: dx = embers(e, 0): dy = embers(e, 1)
cx = cx + dx
cy = cy + dy
'too much like a flower?
midInk 60, 60, 60, red, green, blue, (t - start) / lTail
'midInk 60, 60, 60, 128, 160, 150, (t - start) / lTail
fcirc cx, cy, (t - start) / lTail
dx = dx * .99 'air resitance
dy = dy + .01 'gravity
'COLOR _RGB32(red, green, blue)
cx = cx + dx: cy = cy + dy
fcirc cx, cy, (t - start) / lTail
fw(i).age = fw(i).age + 1
fw(i).x = rand&&(.1 * xmax, .9 * xmax)
fw(i).y = rand&&(.1 * ymax, .5 * ymax)
fw(i).seed = rand&&(0, 32000)
fw(i).age = 0
fw(i).life = rand&&(20, 120)
'Steve McNeil's copied from his forum note: Radius is too common a name
RadiusError = -subRadius
X = subRadius
Y = 0
' Draw the middle span here so we don't draw it twice in the main loop,
' which would be a problem with blending turned on.
Line (CX
- X
, CY
)-(CX
+ X
, CY
), , BF
RadiusError = RadiusError + Y * 2 + 1
Line (CX
- Y
, CY
- X
)-(CX
+ Y
, CY
- X
), , BF
Line (CX
- Y
, CY
+ X
)-(CX
+ Y
, CY
+ X
), , BF
X = X - 1
RadiusError = RadiusError - X * 2
Y = Y + 1
Line (CX
- X
, CY
- Y
)-(CX
+ X
, CY
- Y
), , BF
Line (CX
- X
, CY
+ Y
)-(CX
+ X
, CY
+ Y
), , BF