View.Set ("graphics:640;640,nobuttonbar,offscreenonly")
proc ColorAdd (c1, c2, n : int)
var clr : int
var r1, g1, b1 : real
var r2, g2, b2 : real
var p, p0 : real
RGB.GetColor (c1, r1, g1, b1)
RGB.GetColor (c2, r2, g2, b2)
const a := 50
for i : 1 .. n
p := (i / n) * 100
p0 := 100 - p
clr := RGB.AddColor ((((r1 * p) + (r2 * p0)) / 2) / a, (((g1 * p) + (g2 * p0)) / 2) / a, (((b1 * p) + (b2 * p0)) / 2) / a)
end for
end ColorAdd
const shad := 255
drawfillbox (0, 0, maxx, maxy, 40)
ColorAdd (44, 40, shad div 2)
ColorAdd (40, 44, shad div 2)
type part :
record
x, y, xv, yv, life : real
end record
const numP := 101
const maxLife := 200
var main : array 1 .. numP of part
for i : 1 .. numP
main (i).x := maxx div 2
main (i).y := maxy div 2
main (i).xv := Rand.Int (8, 10) * Rand.Int (-1, 1) * Rand.Real
main (i).yv := Rand.Int (8, 10) * Rand.Int (-1, 1) * Rand.Real
main (i).life := maxLife
end for
loop
for i : 1 .. numP
if main (i).life > 5 then
main (i).x += sin (main (i).y) * main (i).xv
main (i).y += cos (main (i).x) * main (i).yv
main (i).life -= 1
drawfilloval (round (main (i).x), round (main (i).y), 50, 50, round ((main (i).life / maxLife) * shad) + 254)
else
main (i).life := maxLife
end if
end for
View.Update
% drawfillbox (0,0,maxx,maxy,1)
end loop |