@guruchild: Uhm, whats wrong?
@3dZmaster: Cool. This code is for general use, anyone who wants to use it can use it, a thank you or mention in the credits would be nice, but not necessary
.
Okay, this one lets you adjust the amount of rain thats falling, using a simple variable that can be changed in game. No version yet with distance finder, but working on it
`Rain particle generator v2.0
`By Kentaree 19/05/03, last modification 03/07/03
`Code added and/or modified by Duncala
`http://members.lycos.co.uk/darknessrising/
`Setup program environment.
sync on
sync rate 60
autocam off
backdrop on
color backdrop rgb(0,0,0): `Remove this line if you're using DBPro
`Load media.
load image "rain.jpg", 1
`Maximum particle amount and currently shown amount
particleAmount=100
amountShown=50
maxDistance=300
`Set up an array holding position and speed of particles
dim rain(particleAmount,4)
xPos=0
yPos=1
zPos=2
speed=3
`Make all the particles
gosub _setupParticles
do
`Simple test controls, increase or decrease the amount of shown particles if possible
if upkey()=1 and amountShown<particleAmount then inc amountShown
if downkey()=1 and amountShown>0 then dec amountShown
randomize timer()
gosub _moveParticles
text 0,0,"Amount = "+str$(amountShown)
sync
loop
_setupParticles:
`Make textured and ghosted plains numbered 1 to 50, and set transparency on
for i=1 to particleAmount
make object plain i, 1,1
set object i,1,0,0
texture object i,1
ghost object on i
disable object zdepth i
lock object on i
`Setup array values for each particles holding the positional data
rain(i-1,zPos)=(int(rnd(maxDistance)+1))+20: `Z coordinate of particle
rain(i-1,xPos)=(int(rnd(rain(i-1,zPos)*.8)*2+1))-rain(i-1,zPos)*.8: `X coordinate of particle
rain(i-1,yPos)=(int(rnd(rain(i-1,zPos)*.6)*2+1)): `Y coordinate of particle
rain(i-1,speed)=(int(rnd(3)+1+(rain(i-1,zPos)*.6/50))): `Speed of particle
`Position object for start
position object i, rain(i-1,xPos), rain(i-1,yPos), rain(i-1,zPos)
if i>amountShown then hide object i
next i
return
_moveParticles:
for i=1 to particleAmount
if i<=amountShown
if object visible(i)=0 then show object i
`Move particle down according to speed value, which makes a random effect
rain(i-1,yPos)=rain(i-1,yPos)-rain(i-1,speed)
`If particle goes too low, set new position
if rain(i-1,yPos)<-15
rain(i-1,zPos)=(int(rnd(500)+1))+20
rain(i-1,xPos)=(int(rnd(rain(i-1,zPos)*.8)*2+1))-rain(i-1,zPos)*.8
rain(i-1,yPos)=(int(rnd(rain(i-1,zPos)*.6)*2+1))
rain(i-1,speed)=(int(rnd(3)+1+(rain(i-1,zPos)*.6/50)))
endif
`Position particle
position object i, rain(i-1,xPos), rain(i-1,yPos), rain(i-1,zPos)
else
if object visible(i)=1 then hide object i
endif
next i
return
Edit: Quick change to this code, I had a 1 where there was supposed to be an i, so objects didnt reappear when they had to. This is now fixed.
Whatever I did I didn't do it!