Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 My rain program
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ZeroPaladn




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
MiX-MaztA-M8riX




PostPosted: Tue Sep 13, 2005 3:23 pm   Post subject: (No 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
[Gandalf]




PostPosted: Tue Sep 13, 2005 3:55 pm   Post subject: (No 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.
Delos




PostPosted: Tue Sep 13, 2005 7:17 pm   Post subject: (No 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.
ZeroPaladn




PostPosted: Wed Sep 14, 2005 7:14 am   Post subject: (No 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!
codemage




PostPosted: Tue Sep 20, 2005 1:52 pm   Post subject: (No 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)
ZeroPaladn




PostPosted: Tue Sep 20, 2005 3:14 pm   Post subject: (No 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...
goboenomo




PostPosted: Thu Oct 13, 2005 11:41 am   Post subject: (No 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.
Sponsor
Sponsor
Sponsor
sponsor
ZeroPaladn




PostPosted: Fri Oct 14, 2005 8:45 am   Post subject: (No subject)

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




PostPosted: Fri Oct 14, 2005 2:51 pm   Post subject: (No subject)

Draw.Arc

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




PostPosted: 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)
Turing_Gamer




PostPosted: 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
belarussian




PostPosted: Tue Dec 08, 2009 9:18 pm   Post subject: RE:My rain program

ya i do mean that yah
belarussian




PostPosted: 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
mirhagk




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 22 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: