
-----------------------------------
ZeroPaladn
Tue Sep 13, 2005 1:30 pm

My rain program
-----------------------------------
Hi, im back after the summer. sorry about that. anyways this is my first program since i am back in school. if you can in any way shorten it or mod it, id be happy to see your input.

-----------------------------------
MiX-MaztA-M8riX
Tue Sep 13, 2005 3:23 pm


-----------------------------------
Dont have turing at home, but this type of program hasnt been beaten to death yet.. thank god  :roll: havent seen rain in a while... not too shabby


anywho, at least you used ThickLines  :P thats about all I can say

-----------------------------------
[Gandalf]
Tue Sep 13, 2005 3:55 pm


-----------------------------------
Good try, but it would be better if the rain actually moved down.  Still, this is a pretty simple way and it works.

I recall seeing lots of rain/snow programs before, but it's always nice to have fresh input into something :).

-----------------------------------
Delos
Tue Sep 13, 2005 7:17 pm


-----------------------------------
Tidying up time!


var x1, y1, ... : int


You need arrays!


var rainX : array 1..6 of int
var rainY : array 1..6 of int


Or even better yet, records will help you to centralise everything.


var rain :
    record
        x : int
        y : int
    end record

var rainArr : array 1..6 of rain


Now, we need to expidite your coding a little:


    x1 := Rand.Int (1, 600)
    x2 := Rand.Int (1, 600)
    x3 := Rand.Int (1, 600)
    % ...


We'll make a function for that.


function setRain (pX, pY : int) : rain
   var tempRain : rain
   tempRain.x := pX
   tempRain.y := pY
   result rain
end setRain

loop
   for i : 1..upper (rainArr)
      rainArr (i) := setRain (Rand.Int (0, maxx), Rand.Int (0, maxy))
   end for
   %...


We will take note that this does not actually animate the rain.  We simply get lines drawn randomly on the screen.
To achieve said effect, simply set up the rain array initially, then change the x- and y- values as necassary.  This will then form a very primitive particle engine.
Note that with this design, one can also change the 'rain' type to include other properties too.  Of course, remember to change the initialization fcns to reflect these changes as well.

-----------------------------------
ZeroPaladn
Wed Sep 14, 2005 7:14 am


-----------------------------------
thanks for all your help, im currently working on another where the rain moves in a PREDICTABLE path, instead of random lines. this should help me a bit, and im still learing arrays, so i didnt put them in. now i know what to do, and V2 is coming!

-----------------------------------
codemage
Tue Sep 20, 2005 1:52 pm


-----------------------------------
Possible mods:

*Randomize the thickness of your rain
  (Rand.Int(2,4) wood look good with your v.1 settings.)
*Occasional Lightning
*Changing intensity of rain (heavy / light)

-----------------------------------
ZeroPaladn
Tue Sep 20, 2005 3:14 pm


-----------------------------------
all good ideas, but, alas, im working on a new project (see turing applications). Its a Decimal -> Binary converter. My comp Engineering teacher said i could do it for extra credit... heheh... free marks...

-----------------------------------
goboenomo
Thu Oct 13, 2005 11:41 am


-----------------------------------
"]Good try, but it would be better if the rain actually moved down.  Still, this is a pretty simple way and it works.

I recall seeing lots of rain/snow programs before, but it's always nice to have fresh input into something :).

Rain should have moved down for sure.. and i think it would have looked a bit better it the droplets were more oval shaped.

-----------------------------------
ZeroPaladn
Fri Oct 14, 2005 8:45 am


-----------------------------------
is it even possible to draw ovals on an angle (unless you use Pic.New and Pic.Rotate)

-----------------------------------
[Gandalf]
Fri Oct 14, 2005 2:51 pm


-----------------------------------
Draw.Arc

...Or else you could just use boxes/lines...

-----------------------------------
belarussian
Wed Nov 18, 2009 10:10 am

Re: My rain program
-----------------------------------
Ok IF YOU WANT REAL RAIN HERE IT IS

const NoOfrain := 400
var rainX : array 1 .. NoOfrain of int
var rainY : array 1 .. NoOfrain of int

for rain : 1 .. NoOfFlakes
    rainX (rain) := Rand.Int (0, maxx)
    rainY (rain) := Rand.Int (0, maxy)
end for

for rain : 1 .. NoOfrain
        %Drop The rain
        rainY (rain) -= Rand.Int (1, 5)
        %rainX (rain) += Rand.Int (-1, 1)
        if rainY (rain) < 0 then
            rainY (rain) := maxy
            rainY (rain) := Rand.Int (0, maxx)
        end if
        Draw.FillOval (rainX (rain), rainY (rain), 1, 1, blue)
    end for
    %Update the screen (because of offscreen only)
    View.Update
    delay (25)

-----------------------------------
Turing_Gamer
Wed Nov 18, 2009 12:09 pm

Re: My rain program
-----------------------------------

...
for rain : 1 .. NoOfFlakes
    rainX (rain) := Rand.Int (0, maxx)
    rainY (rain) := Rand.Int (0, maxy)
end for
...


Do you mean...
for rain : 1 .. NoOfrain
    rainX (rain) := Rand.Int (0, maxx)
    rainY (rain) := Rand.Int (0, maxy)
end for

-----------------------------------
belarussian
Tue Dec 08, 2009 9:18 pm

RE:My rain program
-----------------------------------
ya i do mean that yah

-----------------------------------
belarussian
Tue Dec 08, 2009 9:23 pm

RE:My rain program
-----------------------------------
View.Set ("graphics:1024;768,nobuttonbar,nocursor,offscreenonly")

loop
    Draw.Fill (100, 100, brightred, green)
    const NoOfrain := 400
    var rainX : array 1 .. NoOfrain of int
    var rainY : array 1 .. NoOfrain of int

    for rain : 1 .. NoOfrain
        rainX (rain) := Rand.Int (0, maxx)
        rainY (rain) := Rand.Int (0, maxy)
    end for

    for rain : 1 .. NoOfrain
        %Drop The rain
        rainY (rain) -= Rand.Int (1, 5)
        %rainX (rain) += Rand.Int (-1, 1)
        if rainY (rain) < 0 then
            rainY (rain) := maxy
            rainY (rain) := Rand.Int (0, maxx)
        end if
        Draw.FillOval (rainX (rain), rainY (rain), 1, 1, blue)
    end for
    %Update the screen (because of offscreen only)

    View.Update
    delay (100)
end loop

-----------------------------------
mirhagk
Tue Dec 08, 2009 11:08 pm

RE:My rain program
-----------------------------------
you want rain, ill give you rain


type RAIN :
    record
        x, y : real
        xv, yv : real
    end record
var rain : array 1 .. 500 of RAIN
setscreen("offscreenonly")
function createrain : RAIN
    var temp : RAIN
    temp.x := Rand.Int (0, maxx)
    temp.y := maxy
    temp.xv := (Rand.Real * 2 - 0.5) / 4
    temp.yv := (Rand.Real * 2)+1
    result temp
end createrain

fcn rainfall (r : RAIN) : RAIN
    var temp := r
    temp.x += temp.xv
    temp.y -= temp.yv
    if temp.y < 0 then
        temp := createrain
    end if
    result temp
end rainfall

proc drawrain (r : RAIN)
    Draw.ThickLine (round (r.x), round (r.y), round (r.x + r.xv), round (r.y + r.yv), 2, brightblue)
end drawrain

for i : 1 .. upper (rain)
    rain (i) := createrain
end for

loop
    for i : 1 .. upper (rain)
        rain (i) := rainfall (rain (i))
    end for
    cls
    for i : 1 .. upper (rain)
        drawrain (rain (i))
    end for
    View.Update
    Time.DelaySinceLast(5)
end loop


-----------------------------------
belarussian
Thu Dec 10, 2009 9:14 pm

RE:My rain program
-----------------------------------
your not really doing any rain that is different than mine you are just changing the y value and making it faster. so yeah have a good day

-----------------------------------
Euphoracle
Thu Dec 10, 2009 9:19 pm

RE:My rain program
-----------------------------------
...You're aware this thread was started in 2005, right?

-----------------------------------
Srlancelot39
Fri Jan 08, 2010 2:15 pm

Re: RE:My rain program
-----------------------------------
you want rain, ill give you rain


type RAIN :
    record
        x, y : real
        xv, yv : real
    end record
var rain : array 1 .. 500 of RAIN
setscreen("offscreenonly")
function createrain : RAIN
    var temp : RAIN
    temp.x := Rand.Int (0, maxx)
    temp.y := maxy
    temp.xv := (Rand.Real * 2 - 0.5) / 4
    temp.yv := (Rand.Real * 2)+1
    result temp
end createrain

fcn rainfall (r : RAIN) : RAIN
    var temp := r
    temp.x += temp.xv
    temp.y -= temp.yv
    if temp.y < 0 then
        temp := createrain
    end if
    result temp
end rainfall

proc drawrain (r : RAIN)
    Draw.ThickLine (round (r.x), round (r.y), round (r.x + r.xv), round (r.y + r.yv), 2, brightblue)
end drawrain

for i : 1 .. upper (rain)
    rain (i) := createrain
end for

loop
    for i : 1 .. upper (rain)
        rain (i) := rainfall (rain (i))
    end for
    cls
    for i : 1 .. upper (rain)
        drawrain (rain (i))
    end for
    View.Update
    Time.DelaySinceLast(5)
end loop


sweet....
I made some modifications too...I altered the code in the first function to make snow, light rain, heavy rain, and even a tornado effect lmao!

-----------------------------------
Srlancelot39
Fri Jan 08, 2010 2:22 pm

Re: RE:My rain program
-----------------------------------
View.Set ("graphics:1024;768,nobuttonbar,nocursor,offscreenonly")

loop
    Draw.Fill (100, 100, brightred, green)
    const NoOfrain := 400
    var rainX : array 1 .. NoOfrain of int
    var rainY : array 1 .. NoOfrain of int

    for rain : 1 .. NoOfrain
        rainX (rain) := Rand.Int (0, maxx)
        rainY (rain) := Rand.Int (0, maxy)
    end for

    for rain : 1 .. NoOfrain
        %Drop The rain
        rainY (rain) -= Rand.Int (1, 5)
        %rainX (rain) += Rand.Int (-1, 1)
        if rainY (rain) < 0 then
            rainY (rain) := maxy
            rainY (rain) := Rand.Int (0, maxx)
        end if
        Draw.FillOval (rainX (rain), rainY (rain), 1, 1, blue)
    end for
    %Update the screen (because of offscreen only)

    View.Update
    delay (100)
end loop

lol...that looks more like particle physics than rain

-----------------------------------
Srlancelot39
Tue Sep 07, 2010 11:12 pm

Re: RE:My rain program
-----------------------------------
your not really doing any rain that is different than mine you are just changing the y value and making it faster. so yeah have a good day
really?  looks significantly different to me.  besides, mirhagk is a good sport, you're not - "so yeah have a good day".....honestly?  sounds like jealousy to me...

-----------------------------------
andrew.
Wed Sep 08, 2010 6:57 am

Re: RE:My rain program
-----------------------------------
To quote Euphoracle:
...You're aware this thread was started in 2005, right?

-----------------------------------
Dan
Wed Sep 08, 2010 9:18 am

RE:My rain program
-----------------------------------
Thread locked due to necroposting.
