|
Malboro
|
Posté le 09 Mai 2010 à 19:04
|
|

Messages : 13
GCPoints : 3852
|
Pour tout ceux qui voudrai faire de la plus avec dbp voici un petit code :
Citation :sync on
sync rate 30
autocam off
color backdrop 0
randomize timer()
make object box 1,.1,.1,.1
position camera 0,5,0
hide object 1
set ambient light 50
sw=screen width()
while spacekey()=0
speed#=0
if inkey$()="z" then speed#=.4
if inkey$()="s" then speed#=-.4
move camera speed#
move object 1,speed#
gosub draw_rain
text 0,20,"fps= "+str$(screen fps())
sync
endwhile
end
draw_rain:
base=600
raindrops=100
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
if object exist(base)=0
make particles base,0,10000,1
set particle life base,1
make object box base,.1,.1,.1
set object light base,1
ghost object on base
color object base,rgb(0,0,255)
color particles base,192,192,192
fade object base,15
set object collision off base
for i=base+1 to base+raindrops
make particles i,0,10000,1
set particle life i,1
clone object i,base
set object light i,1
ghost object on i
color object i,rgb(0,0,255)
color particles i,192,192,192
fade object i,15
set object collision off i
next i
endif
for i=base to base+raindrops
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
scale object i,100,10,10*rnd(300)
set object to object orientation i,1
pitch object down i,90
move object i,1+dist#/100
if object position y(i)<=0
position particles i,object position x(i),0,object position z(i)
endif
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#
|
|
Darktib
|
Posté le 09 Mai 2010 à 22:12
|
|

Messages : 4017
GCPoints : 347288
|
Très sympa comme effet.
Par contre en faisant attention on voit bien qu'il s'agit de 2 effets séparés, la pluie en 2D et les particules en 3D.
Enfin, c'est toujours un très bon code!
|
|
Mod
|
Posté le 12 Mai 2010 à 12:46
|
|

Messages : 4954
GCPoints : 2100823
|
Assez sympa oui.
Histoire d'optimiser un peu, je suggèrerais de travailler avec les distances au carré plutôt que d'utiliser des racines carrées pour avoir les distances réelles. Racine carrées et rapidité, ça fait deux.
Et merci pour ce code :).
|