fb:porticula NoPaste
Fireworks
Uploader: | psygate |
Datum/Zeit: | 21.07.2006 16:00:22 |
'Fireworks, programmed and developed by psygate
'21. July 2006
'Use as you like. Use at your own risk.
option explicit
randomize timer
'-------------------------------------------------------------------------------
'Type Declaretion:
type rocket
x as integer 'X-Coordinates (Launch rocket from the middle: no use anymore)
y as integer 'Y-Coordinates
maxy as integer 'Highest Point, where the rocket should explode
c as integer 'Color of the rocket
end type
type particle
x as double 'X-Yadda Yadda, you know...
y as double '^Look up^
xo as uinteger 'Old Coordinates can never be negative
yo as uinteger '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
vx as double 'Speed of the Particle on the x-Axes
vy as double '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^y-Axes
ax as double 'acceleration of the particle in x-direction.
ay as double '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^y-direction.
r as ubyte 'Red part of the particle color.
g as ubyte 'green^^^^^^^^^^^^^^^^^^^^^^^^^^
b as ubyte 'blue^^^^^^^^^^^^^^^^^^^^^^^^^^^
end type
'-------------------------------------------------------------------------------
const gravity=0.1
const maxvx=2
const maxvy=10
dim as uinteger xmax,ymax,c,dots,blend,r,meanb
dim as double t
dim as ubyte pointer image
dim as string key
'-----------------------------------------------
'Get number oof performed Operations per second:
t=timer+1
while t>timer
dots+=1
wend
dots=dots\200 'Divide by hundret because in mainloop you dont just add
'1 to every pixel. (PSET usw...)
'-----------------------------------------------
dim as rocket flight
dim as particle dot(dots)
'-------------------------------------------------------------------------------
'Get info about the screen end set it.
screeninfo xmax,ymax
screenres xmax,ymax,32,,1
image=imagecreate(xmax,ymax,0)
'-------------------------------------------------------------------------------
'Start the flight:
do
with flight
.x=int(rnd*xmax)
.y=ymax-1
.maxy=int(rnd*ymax)
.c=rgb(int(rnd*256),int(rnd*256),int(rnd*256))
while .y<>.maxy
.y-=1
pset(.x,.y+1),0
pset(.x,.y),.c
sleep 1 'If you don't wait a while the rocket would be too fast.
if inkey$<>"" then exit while
wend
end with
key=inkey$
key=""
for c= 1 to dots
with dot(c)
.x=flight.x
.y=flight.maxy
.xo=.x
.yo=.y
.vx=(rnd*maxvx)*(-1)^int(rnd*2)
.vy=rnd*maxvy*(-1)
.ax=0.01*rnd*(abs(.vx)/.vx)
.ay=gravity
.r=int(rnd*256)
.g=(.r\2+int(rnd*10))*0^int(rnd*2)
.b=0
end with
next
t=(10+10*rnd)+timer
blend=100
do
screenlock
' if t<timer then blend+=1
put (0,0),image,alpha,blend
r=0
for c=1 to dots
with dot(c)
pset(.x,.y),rgb(.r,.g,.b)
.x+=.vx
.y+=.vy
.vx+=.ax
.vy+=.ay
if t-timer<0 and (.x>xmax-1 or .y>ymax-1 or .x<0) then r+=1
if (.x>xmax-1 or .y>ymax-1) and t-timer>0 then
.x=flight.x
.y=flight.y
' flight.x-=0.1
flight.y-=0.1
.xo=.x
.yo=.y
.vx=(rnd*maxvx)*(-1)^int(rnd*2)
.vy=rnd*maxvy*(-1)
.ax=0.01*rnd*(abs(.vx)/.vx)
.ay=gravity
.r=int(rnd*256)
.g=(.r\2+int(rnd*10))*0^int(rnd*2)
.b=meanb+int(rnd*(256-meanb))
if t-timer<3 then meanb+=1:meanb=meanb mod 255
if t-timer<1 then .r=255:.g=255:.b=255
end if
end with
next
screenunlock
key=inkey$
loop until key<>"" or r=dots-1
put(0,0),image,pset
loop until key<>""