Main Menu

Rain effect

Started by ATLUS, November 09, 2008, 06:13:24 AM

Previous topic - Next topic

ATLUS

so i see blitz3d demo and see examples rain source and i want converct its in PlayBasic but types command different :) so see this
; PROJECT : Project1
; AUTHOR  : ATLUS
; CREATED : 09.11.2008
; EDITED  : 09.11.2008
; ---------------------------------------------------------------------

Global drop_number=200


Type drop
x,y
angle,col
EndType
Dim drip as drop
Global wind
placedrops()
do
Cls rgb(0,0,0)
update()
If leftkey()=1 Then wind=wind-25
If rightkey()=1 Then wind=wind+25
If wind>3000 Then wind=3000
If wind<-3000 Then wind=-3000
print "Wind speed:"+str$(wind)
print "Numpad left and right adjust wind speed"
sync
loop

;place drops on the screen
Function placedrops()
For n=0 To drop_number
  drip.drop = New drop
  al=Rnd(2048)
  drip\x=al-704
  drip\y=Rnd(380)
  drip\angle=0     ;straight down (This is modified by wind)
  drip\col=Rnd(4)
Next
EndFunction

Function update()
;adjust the 12 at the end of the Sin and Cos lines for faster rain
For drip.drop = Each drop
  xx=Sin((2*(drip\angle+wind))*Pi/360)*12
  yy=Cos((2*(drip\angle+wind))*Pi/360)*12
  If drip\col=0 Then Color 200,200,200 Else
  If drip\col=1 Then Color 150,150,150 Else
  If drip\col=2 Then Color 100,100,100 Else
  If drip\col=3 Then Color 50,50,50
  Line drip\x,drip\y,drip\x+(xx/2),drip\y+(yy/2)
  drip\x=drip\x+xx
  drip\y=drip\y+yy
  If drip\y>430
   percent=Rnd(100)
   If percent<50 Or drip\y>475
    al=Rnd(2048)
    drip\x=al-704
    drip\y=Rnd(100)
    drip\angle=0     ;straight down (This is modified by wind)
   EndIf
  EndIf
Next
EndFunction

kevin



Global drop_number=200

Type drop
x,y
angle
col
EndType
Dim drip as drop list
Global wind
placedrops()
do
Cls rgb(0,0,0)
update()
If leftkey()=1 Then wind=wind-25
If rightkey()=1 Then wind=wind+25
If wind>3000 Then wind=3000
If wind<-3000 Then wind=-3000
print "Wind speed:"+str$(wind)
print "Numpad left and right adjust wind speed"
sync
loop

;place drops on the screen
Function placedrops()
For n=0 To drop_number
  drip = New drop
  al=Rnd(2048)
  drip.x=al-704
  drip.y=Rnd(380)
  drip.angle=0     ;straight down (This is modified by wind)
  drip.col=Rnd(4)
Next
EndFunction

Function update()
;adjust the 12 at the end of the Sin and Cos lines for faster rain
For each drip()
  xx=Sin((2*(drip.angle+wind))*Pi/360)*12
  yy=Cos((2*(drip.angle+wind))*Pi/360)*12
  If drip.col=0
  ink rgb(200,200,200)
  elseIf drip.col=1
   ink rgb(150,150,150)
  elseIf drip.col=2
   ink rgb(100,100,100)
  elseif drip.col=3
   ink rgb(50,50,50)
  endif

  Line drip.x,drip.y,drip.x+(xx/2),drip.y+(yy/2)
  drip.x=drip.x+xx
  drip.y=drip.y+yy

  If drip.y>430
   percent=Rnd(100)
   If percent<50 Or drip.y>475
    al=Rnd(2048)
    drip.x=al-704
    drip.y=Rnd(100)
    drip.angle=0     ;straight down (This is modified by wind)
   EndIf
  EndIf
Next
EndFunction

ATLUS

Nice effect Thanks Kevin!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! but wind not work

kevin



Global drop_number=200
Global wind

Type drop
x,y
angle
col
EndType
Dim drip as drop list
placedrops()
do
Cls rgb(0,0,0)
update()
If leftkey()=1 Then wind=wind-25
If rightkey()=1 Then wind=wind+25
If wind>3000 Then wind=3000
If wind<-3000 Then wind=-3000
print "Wind speed:"+str$(wind)
print "Numpad left and right adjust wind speed"
sync
loop

;place drops on the screen
Function placedrops()
For n=0 To drop_number
  drip = New drop
  al=Rnd(2048)
  drip.x=al-704
  drip.y=Rnd(380)
  drip.angle=0     ;straight down (This is modified by wind)
  drip.col=Rnd(4)
Next
EndFunction

Function update()
;adjust the 12 at the end of the Sin and Cos lines for faster rain
For each drip()
  Angle#=(2*(drip.angle+wind))*Pi#/360
  xx=SinRadius(angle#,12)
  yy=CosRadius(angle#,12)
  c=(4-drip.col)*50
  Linec drip.x,drip.y,drip.x+(xx/2),drip.y+(yy/2),rgb(c,c,c)
  drip.x=drip.x+xx
  drip.y=drip.y+yy

  If drip.y>430
   percent=Rnd(100)
   If percent<50 Or drip.y>475
    al=Rnd(2048)
    drip.x=al-704
    drip.y=Rnd(100)
    drip.angle=0     ;straight down (This is modified by wind)
  EndIf
  EndIf
Next
EndFunction


ATLUS

great  :o Thanks Kevin !!!!!!!!!!!!