`====================== `SNOW: A WEATHER EFFECT `BY ALEX JONES (INH) `====================== sync on sync rate 30 autocam off gosub images gosub createobjects `========= `MAIN LOOP `========= x#=0 ink rgb(0,0,0),0 do for t=1 to 700 if rnd(3)=0 then sy#=0 if rnd(3)=1 then sy#=0.2 if rnd(3)=2 then sy#=0.4 if rnd(3)=3 then sy#=0.6 yrotate object t,wrapvalue(object angle y(t)+rnd(2)) zrotate object t,wrapvalue(object angle z(t)+10+rnd(10)) move object t,sy# if object position y(t)<-5+mhh# then position object t,-19+x#,30+rnd(50),30+rnd(10) : inc sfn,1 : inc x#,0.2 : inc mmh#,0.0007 position object (t),object position x(t),object position y(t)-0.2,object position z(t) next t if sfn=>700 then x#=0 : sfn=0 position matrix 1,-200,-5+mmh#,-10 if matrix position y(1)>0.4 then gosub lowermatrix remstart rem Use MOUSEMOVE to alter camera angles cx#=wrapvalue(cx#+mousemovey()) cy#=wrapvalue(cy#+mousemovex()) cz#=wrapvalue(cz#+mousemovez()) rotate camera cx#,cy#,cz# rem Simple movement if upkey()=1 then move camera 25 if downkey()=1 then move camera -25 remend sync loop `====================== `LOWER THE MATRIX AGAIN `====================== lowermatrix: for t=255 to 15 step -20 set gamma t,t,t sync next t mmh#=0 position matrix 1,-200,-5+mmh#,-10 for t=15 to 255 step 20 set gamma t,t,t sync next t return `============ `============ `MAKE OBJECTS `============ `============ createobjects: `========== `SNOWFLAKES `========== for t=1 to 700 make object box (t),1,0.01,1 position object (t),-19+x#,-10+rnd(50),20+rnd(10) texture object (t),1 set object (t),1,0,1 inc x#,0.2 xrotate object t,90 next t `========= `SKYSPHERE `========= make object sphere 701,700 texture object 701,2 set object 701,1,1,0 position object 701,0,0,0 `====== `MATRIX `====== make matrix 1,400,400,40,40 position matrix 1,-200,0,-10 position camera 30,5,-10 prepare matrix texture 1,3,1,1 randomize matrix 1,6 for t=0 to 40 for mhy=21 to 40 set matrix height 1,t,mhy,-91+(mhy*5)+rnd(20) next mhy next t update matrix 1 Normalise(1) return `====== `IMAGES `====== images: cls ink rgb(255,255,255),0 box 90,0,110,200 box 0,90,200,110 for t=40 to 60 circle 100,100,t next t get image 1,0,0,201,201 cls for t=0 to 100 ink rgb(55+(t),55+(t),100+t),0 line 0,t,100,t next t ink rgb(255,255,255),0 box 0,100,100,120 get image 2,0,0,101,121 cls for t=0 to 100 ink rgb(255-(t/5),255-(t/5),255-(t/5)),0 box 0+t,0+t,100-t,100-t next t get image 3,0,0,101,101 rem add a little lighting for dbc 1.20 color ambient light 0 set ambient light 50 make light 1 set directional light 0,.5,-1,0 return Function Normalise(MatNum) For z=1 to 40 For x=1 to 40 h8#=get matrix height(MatNum,x,z-1)*5 h4#=get matrix height(MatNum,x-1,z)*5 h#=get matrix height(MatNum,x,z)*5 h2#=get matrix height(MatNum,x,z)*5 x1#=(x-1)*25.0 y1#=h# x2#=(x+0)*25.0 y2#=h4# dx#=x2#-x1# dy#=y2#-y1# ax#=atanfull(dx#,dy#) ax#=wrapvalue(90-ax#) z1#=(z-1)*25.0 y1#=h2# z2#=(z+0)*25.0 y2#=h8# dz#=z2#-z1# dy#=y2#-y1# az#=atanfull(dz#,dy#) az#=wrapvalue(90-az#) nx#=sin(ax#) ny#=cos(ax#) nz#=sin(az#) Set matrix normal MatNum,x,z,nx#,ny#,nz# next x next z Update Matrix MatNum EndFunction