Computer Science Canada

My rain program

Author:  ZeroPaladn [ Tue Sep 13, 2005 1:30 pm ]
Post subject:  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.

Author:  MiX-MaztA-M8riX [ Tue Sep 13, 2005 3:23 pm ]
Post subject: 

Dont have turing at home, but this type of program hasnt been beaten to death yet.. thank god Rolling Eyes havent seen rain in a while... not too shabby


anywho, at least you used ThickLines Razz thats about all I can say

Author:  [Gandalf] [ Tue Sep 13, 2005 3:55 pm ]
Post subject: 

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 Smile.

Author:  Delos [ Tue Sep 13, 2005 7:17 pm ]
Post subject: 

Tidying up time!

code:

var x1, y1, ... : int


You need arrays!

Turing:

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.

Turing:

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:

code:

    x1 := Rand.Int (1, 600)
    x2 := Rand.Int (1, 600)
    x3 := Rand.Int (1, 600)
    % ...


We'll make a function for that.

Turing:

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.

Author:  ZeroPaladn [ Wed Sep 14, 2005 7:14 am ]
Post subject: 

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!

Author:  codemage [ Tue Sep 20, 2005 1:52 pm ]
Post subject: 

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)

Author:  ZeroPaladn [ Tue Sep 20, 2005 3:14 pm ]
Post subject: 

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...

Author:  goboenomo [ Thu Oct 13, 2005 11:41 am ]
Post subject: 

[Gandalf] wrote:
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 Smile.


Rain should have moved down for sure.. and i think it would have looked a bit better it the droplets were more oval shaped.

Author:  ZeroPaladn [ Fri Oct 14, 2005 8:45 am ]
Post subject: 

is it even possible to draw ovals on an angle (unless you use Pic.New and Pic.Rotate)

Author:  [Gandalf] [ Fri Oct 14, 2005 2:51 pm ]
Post subject: 

Draw.Arc

...Or else you could just use boxes/lines...

Author:  belarussian [ Wed Nov 18, 2009 10:10 am ]
Post subject:  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)

Author:  Turing_Gamer [ Wed Nov 18, 2009 12:09 pm ]
Post subject:  Re: My rain program

belarussian @ Wed Nov 18, 2009 10:10 am wrote:

...
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

Author:  belarussian [ Tue Dec 08, 2009 9:18 pm ]
Post subject:  RE:My rain program

ya i do mean that yah

Author:  belarussian [ Tue Dec 08, 2009 9:23 pm ]
Post subject:  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

Author:  mirhagk [ Tue Dec 08, 2009 11:08 pm ]
Post subject:  RE:My rain program

you want rain, ill give you rain

Turing:

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

Author:  belarussian [ Thu Dec 10, 2009 9:14 pm ]
Post subject:  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

Author:  Euphoracle [ Thu Dec 10, 2009 9:19 pm ]
Post subject:  RE:My rain program

...You're aware this thread was started in 2005, right?

Author:  Srlancelot39 [ Fri Jan 08, 2010 2:15 pm ]
Post subject:  Re: RE:My rain program

mirhagk @ Tue Dec 08, 2009 10:08 pm wrote:
you want rain, ill give you rain

Turing:

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!

Author:  Srlancelot39 [ Fri Jan 08, 2010 2:22 pm ]
Post subject:  Re: RE:My rain program

belarussian @ Tue Dec 08, 2009 8:23 pm wrote:
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

Author:  Srlancelot39 [ Tue Sep 07, 2010 11:12 pm ]
Post subject:  Re: RE:My rain program

belarussian @ Thu Dec 10, 2009 8:14 pm wrote:
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...

Author:  andrew. [ Wed Sep 08, 2010 6:57 am ]
Post subject:  Re: RE:My rain program

To quote Euphoracle:
Euphoracle @ Thu Dec 10, 2009 9:19 pm wrote:
...You're aware this thread was started in 2005, right?

Author:  Dan [ Wed Sep 08, 2010 9:18 am ]
Post subject:  RE:My rain program

Thread locked due to necroposting.


: