Type Vectors
x As Float
y As Float
z As Float
EndType
Type Particle
p As Vectors
v As Vectors
f As Float
EndType
make object plain 1003,1000,1000
xrotate object 1003, 90
make object triangle 1001,-0.1,4,0,0,-4,0,0.1,4,0
cls
ink rgb(100,100,100),0
box 0,0,2,2
get image 1,0,0,2,2
ttlRain = 250
DIM Particles(ttlRain) As Particle
for x=1 to ttlRain
clone object x, 1001
set object light x,0
texture object x, 1
next x
delete object 1001
GOSUB Camera_Setup
i = 1
sync on
do
if upkey() then windz# = windz# + 0.01
if downkey() then windz# = windz# - 0.01
if rightkey() then windx# = windx# + 0.01
if leftkey() then windx# = windx# - 0.01
if windx# > 0.5 then windx# = 0.5
if windx# < -0.5 then windx# = -0.5
if windz# > 0.5 then windz# = 0.5
if windz# < -0.5 then windz# = -0.5
if spacekey() = 1 and rainIt = 0 then rainIt = 1
if rainIt = 1
rainIt = 2
inc rain
if rain > 1 then rain = 0
endif
if spacekey() = 0 then rainIt = 0
if rain = 1
for t=1 to ttlRain
Particles(t).p.x = Particles(t).p.x + Particles(t).v.x + windx#
Particles(t).p.y = Particles(t).p.y + Particles(t).v.y
Particles(t).p.z = Particles(t).p.z + Particles(t).v.z + windz#
`Particles(t).p.x = Particles(t).p.x * 0.99
`Particles(t).p.y = Particles(t).p.y * 0.99
`Particles(t).p.z = Particles(t).p.z * 0.99
`Position, scale and fade particle object
position object t,Particles(t).p.x,Particles(t).p.y,Particles(t).p.z
yrotate object t, camera angle y()
next t
inc i
if i > ttlRain then i = 1
`if Particles(i).p.y < 0.0 then i=1
`Position
Particles(i).p.x = camera position x() + (rnd(500)-250)
Particles(i).p.y = camera position y() + 200.0
Particles(i).p.z = camera position z() + (rnd(500)-250)
`Velocity (randomize)
Particles(i).v.x = 0.0
Particles(i).v.y = -1.0
Particles(i).v.z = 0.0
`Show the particle
show object i
endif
GOSUB Camera_Free_Loop
`if spacekey() = 0 then bomb = 0
text 0,0,"press space to rain"
text 0,12,"control camera with mouse and wasd keys"
text 0,24,"arrowkeys to control wind direction"
text 0,36,str$(windx#) + " " + str$(windz#)
sync
loop
Camera_Setup:
dummyCam = 1002
Cam_Start_X# = 0.0
Cam_Start_Y# = 0.0
Cam_Start_Z# = 0.0
MAKE OBJECT BOX dummyCam, 5, 5, 5 : HIDE OBJECT dummyCam
REM POSITION THE START CAMERA
POSITION OBJECT dummyCam, Cam_Start_X#, Cam_Start_Y#, Cam_Start_Z#
camMoveSpeed# = 1.0 : mouseSpeed = 4
SET CAMERA RANGE 0.1, 100000
RETURN
`-----------FREE CAMERA LOOP-----------
Camera_Free_Loop:
if shiftkey() > 0
inc camMoveSpeed#, 0.1
if camMoveSpeed# => 10.0 then camMoveSpeed# = 10.0
else
if camMoveSpeed# > 1.0
dec camMoveSpeed#, 0.1
if camMoveSpeed# =< 1.0 then camMoveSpeed# = 1.0
endif
endif
if keystate(17)=1 then MOVE OBJECT dummyCam, camMoveSpeed#
if keystate(30)=1 then MOVE OBJECT LEFT dummyCam, camMoveSpeed#
if keystate(31)=1 then MOVE OBJECT dummyCam, -camMoveSpeed#
if keystate(32)=1 then MOVE OBJECT RIGHT dummyCam, camMoveSpeed#
rem camera rotation
camAngX# = wrapvalue((mousemovey() / mouseSpeed) + camAngX#)
camAngY# = wrapvalue((mousemovex() / mouseSpeed) + camAngY#)
rem stops mouse from going upside down
if camAngX# > 80 and camAngX# < 180 then camAngX# = 80
if camAngX# > 180 and camAngX# < 310 then camAngX# = 310
ROTATE OBJECT dummyCam, camAngX#, camAngY#, object angle z(dummyCam)
camPosX# = object position x(dummyCam)
camPosY# = object position y(dummyCam)
camPosZ# = object position z(dummyCam)
camAngX# = object angle x(dummyCam)
camAngY# = object angle y(dummyCam)
camAngZ# = object angle z(dummyCam)
POSITION CAMERA 0, camPosX#, camPosY#, camPosZ#
ROTATE CAMERA 0, camAngX#, camAngY#, object angle z(dummyCam)
RETURN