Here is a fireworks display I fit into 20 lines.
editting first post....
The code 20 line code didn't post correctly, I will try again.
The geocities won't let you get to the media file from here,
so use your browser to get them from:
www.geocities.com/billrlw/fireworks.zip
Here is the readable version first.
` Program: Fireworks
` Created: 1-30-03
` Modified: 4/4/03
`Thanks to DBHeaven for their tutorial on gravity!
HIDE MOUSE
SYNC ON
SYNC RATE 60
set display mode 800,600,32
dim xpos#(20,2)
dim ypos#(20,2)
dim xspeed#(20)
dim yspeed#(20)
dim dist(20):`distance shell travels before exploding
dim color(20)
dim colortable(10)
` explosion arrays explx=x, exply=y, expldur=star duration, expldirx=x vector of star, expldiry=y vector of star
dim explx#(20,225)
dim exply#(20,225)
dim expldur(20,225)
dim expldirx#(20,225)
dim expldiry#(20,225)
dim busy(20)
dim stars(16,16)
dim bitmaps(6)
colordata:
data 255,255,255
data 255,0,0
data 0,255,0
data 0,0,255
data 255,0,255
data 255,255,0
data 0,255,255
data 255,128,0
data 255,0,128
load sound "mortar1.wav",1
load sound "FireworksBurst.wav",2
set sound volume 1,90
for i=1 to 9
read c1,c2,c3
colortable(i)=rgb(c1,c2,c3)
next i
RED=rgb(255,0,0)
WHITE=rgb(255,255,255)
yspeed#(1) = 5.0
xspeed#(1) = 1.0
acc# = 0.1
gravity# = 0.04
wind# = 0.01
global stargravity#=.008
`you can change the maxshells value for increased frame rate
global maxshells=10
global numshells=0
t=timer()
randomize t
cls 0
sync
load bitmap "FW-bloom.bmp",1
load bitmap "FW-square.bmp",2
load bitmap "FW-ring.bmp",3
load bitmap "FW-star.bmp",4
load bitmap "FW-theend.bmp",5
load bitmap "FW-fireworks.bmp",6
set current bitmap 0
i=1
texty=1
do
if numshells<maxshells
for i=1 to maxshells
if busy(i)=0 and dist(i)=0:`shell not busy, fire away
yspeed#(i)=abs(cos(rnd(360))*4.5)+2
xspeed#(i)=cos(rnd(360))*1.6
xpos#(i,1)=400
ypos#(i,1)=560
xpos#(i,2)=xpos#(i,1)-(xspeed#(i)*2)
ypos#(i,2)=ypos#(i,1)+(yspeed#(i)*2)
dist(i)=yspeed#(i)*27+rnd(25)
color(i)=colortable(rnd(8)+1)
numshells=numshells+1
play sound 1
endif
next i
endif
`-----------------------------------------------------
`checks for exploded shells, displays stars until they fade away
for i=1 to maxshells:` posible 20 exploding shells each with 225 stars
if busy(i)=1:`stars from exploding shell still visible and expanding
doneflag=1
for st=1 to 225
ink 0,0
dot explx#(i,st),exply#(i,st)
ink color(i),0
expldur(i,st)=expldur(i,st)-1
if expldur(i,st)>0
explx#(i,st)=explx#(i,st)+expldirx#(i,st)
exply#(i,st)=exply#(i,st)+expldiry#(i,st)
expldirx#(i,st)=expldirx#(i,st)/1.01
expldiry#(i,st)=expldiry#(i,st)/1.01+stargravity#
ink color(i),0
dot explx#(i,st),exply#(i,st)
doneflag=0
endif
next st
if doneflag=1 then busy(i)=0
endif
next i
`draws mortar shot and trail until shell explodes
for i=1 to maxshells
`Draws mortar shell after firing in the sky
if dist(i)>0
ink 0,0
line xpos#(i,1),ypos#(i,1),xpos#(i,2),ypos#(i,2):`erase last fuse line
dist(i)=dist(i)-1
if dist(i)=0:`counter has reached zero, explode mortar shell in the sky
numshells=numshells-1
_load_star(i)
busy(i)=1
play sound 2
else
xpos#(i,2)=xpos#(i,1)-xspeed#(i)
ypos#(i,2)=ypos#(i,1)+yspeed#(i)
yspeed#(i)=yspeed#(i)-gravity#
xpos#(i,1)=xpos#(i,1)+xspeed#(i)
ypos#(i,1)=ypos#(i,1)-yspeed#(i)
ink color(i),0
line xpos#(i,1),ypos#(i,1),xpos#(i,2),ypos#(i,2):`draw updated fuse line
endif
endif
next i
sync
loop
function _load_star(index)
`mostly round bloom star bursts - 20% will be special design star bursts(image maps 2-6)
stnum=rnd(100)
if stnum<80 then stnum=1 else stnum=rnd(5)+1
set current bitmap stnum
ink WHITE,0
starindex=1
for i=0 to 14
for j=0 to 14
set current bitmap stnum
v=point (i,j)
if v>0
explx#(index,starindex)=xpos#(index,1)+(i-8)
exply#(index,starindex)=ypos#(index,1)+(j-8)
expldur(index,starindex)=125+rnd(55)
set current bitmap 0
dot explx#(index,starindex),exply#(index,starindex)
if stnum=1 then power#=(1.0*rnd(5)+6) else power#=10.0:`scatter burst stars, except for pattern shells 2-6
expldirx#(index,starindex)=(explx#(index,starindex)-xpos#(index,1))/power#
expldiry#(index,starindex)=(exply#(index,starindex)-ypos#(index,1))/power#
endif
starindex=starindex+1
next j
next i
set current bitmap 0
endfunction
Hope it worked this time!