added more snow, slower snow, and movement in all directions (use your arrow keys)
+ Code SnippetREM Project: snow_fx
REM Created: 24/06/2007 09:40:17
REM
REM ***** Main Source File *****
REM
Rem Project: 3D Rain
Rem Created: 09/11/2004 19:28:15
Rem ***** Main Source File *****
sync on
sync rate 60
autocam off
color backdrop rgb(200,200,255)
randomize timer()
rem Make a dummy object to be moved with the camera as camera angles give funny results.
make object box 1,.1,.1,.1
hide object 1
MatrixNumber=1
make matrix MatrixNumber,2000,2000,25,25
RANDOMIZE MATRIX MatrixNumber, 100
SET MATRIX WIREFRAME OFF MatrixNumber
POSITION MATRIX MatrixNumber, camera position X()-1000, camera position Y()-200, camera position Z()-1000
GHOST MATRIX ON MatrixNumber
set ambient light 50
FOG ON
FOG DISTANCE 1000 : FOG COLOR RGB(255,255,255)
fog on
sw=screen width()
while spacekey()=0
speed#=0
speed#=0.8
control camera using arrowkeys 0,speed#,(speed#/4.0)
rem move camera speed#
move object 1,speed#
gosub draw_rain
text 0,0,"3D Rain - Written by Jason Clogg"
text 0,20,"fps= "+str$(screen fps())
text 0,40,"Snow version update by GatorHex (use arrowkeys to move)"
sync
endwhile
end
draw_rain:
rem base sprite number
base=600
rem How many raindrops to display
raindrops=500
`Calculate a point in front of the camera to start drawing the starfield
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
if object exist(base)=0
make object box base,.1,.1,.1
set object light base,0
ghost object on base
color object base,rgb(255,255,255)
fade object base,50
set object collision off base
rem yrotate object base, 270
for i=base+1 to base+raindrops
clone object i,base
rem rain should not be affected by light or included in collisions
set object light i,0
ghost object on i
color object i,rgb(255,255,255)
fade object i,50
set object collision off i
` position object i,rnd(spread*2)-spread,rnd(spread*2)-spread,camera position z()+rnd(dist)
next i
endif
for i=base to base+raindrops
`reposition rain if they are out of camera shot
if object in screen(i)=0
screenx#=rnd(sw):screeny#=0
dist#=rnd(200)+10
pick screen screenx#,screeny#,dist#
sx#=get pick vector x()
sy#=get pick vector y()
sz#=get pick vector z()
position object i,cx#+sx#,cy#+sy#,cz#+sz#
endif
`Calculate distance of star from camera and scale star accordingly
scale object i,1000,10,10*rnd(300)
rem set object to object orientation i,1
set object to camera orientation i
pitch object down i,90
move object i,0.7+dist#/1000
next i
return
function distance(x1#,y1#,z1#,obj)
x2#=object position x(obj)
y2#=object position y(obj)
z2#=object position z(obj)
dist#=sqrt((x1#-x2#)*(x1#-x2#)+(y1#-y2#)*(y1#-y2#)+(z1#-z2#)*(z1#-z2#))
endfunction dist#