Computer Science Canada

::RAIN RENDER::

Author:  MihaiG [ Mon Nov 29, 2004 6:58 pm ]
Post subject:  ::RAIN RENDER::

here is an awesome render of rain i made

code:

var n : int
n := 1000
var x, y, l : array 1 .. n of int
for i : 1 .. n
    randint (l (i),1,5)
    randint (x (i), 1, maxx - l(i))
    randint (y (i), l(i), maxy)
end for
loop
    for i : 1 .. n
        if y (i) < maxy - l (i) then
            drawline (x (i), y (i), x (i), y (i) + l(i) , white)
        else
            drawline (x (i), maxy, x (i), y (i), white)
        end if
        if y (i) <= l(i) then
            randint (x (i), 1, maxx)
            y (i) := maxy
        else
            y (i) := y (i) - l(i)
        end if
        drawline (x (i), y (i) + l(i), x (i), y (i), blue)
    end for
end loop



please i need the precious bits...

Author:  cool dude [ Mon Nov 29, 2004 7:04 pm ]
Post subject: 

we r learning arrays in class right now, and i learned a little from your program even though it doesn't do much. anyways nice try.

p.s. i like your quote

Author:  Tony [ Mon Nov 29, 2004 8:15 pm ]
Post subject: 

the problem is that all raindrops look identical and fall in a plane Confused

Author:  Neo [ Mon Nov 29, 2004 8:24 pm ]
Post subject: 

Some minor improvements:

code:

View.Set ("graphics:550;350,offscreenonly")
const raincount := 25
var speed := 5
var rain,xr,yr : array 1 .. raincount of int
Draw.FillOval (106, 69, 4, 4, brightblue)
Draw.ThickLine (105, 73, 113, 78, 1, brightblue)
Draw.ThickLine (110, 69, 113, 78, 1, brightblue)
drawfill (109, 74, brightcyan, brightblue)

for num : 1 .. raincount
    rain (num) := Pic.New (100, 65, 115, 79)
    xr (num) := Rand.Int (0, maxx)
    yr (num) := Rand.Int (0, maxy)
end for

loop
    drawfillbox (0, 0, maxx, maxy, black)

    for num : 1 .. raincount
        Pic.Draw (rain (num), xr (num), yr (num), picMerge)
        yr (num) -= speed
        xr (num) -= speed
        if xr (num) < -10 or yr (num) < -10 then
            xr (num) := Rand.Int (0, maxx + 300)
            yr (num) := Rand.Int (maxy + 50, maxy + 100)
        end if
    end for

    delay (10)
    View.Update
end loop

Author:  MihaiG [ Mon Nov 29, 2004 8:31 pm ]
Post subject: 

well ur runs slow at a high number(500-1000) of drops while mine runs slow after 100,000 so its better for "heavy"rain Wink
-edit-
i like my qoute too
take that tony i fixed ur request of making random lengths check code above

Author:  Tony [ Mon Nov 29, 2004 11:14 pm ]
Post subject: 

still needs some tweaking to do. Some drops are unreasonably slow Confused

you should also make drops to be of different colour and make it a gradient background.. or an image Very Happy

Author:  RaPsCaLLioN [ Mon Nov 29, 2004 11:24 pm ]
Post subject: 

Over-complicated? I'm gonna work on water beading of the screen next.

code:
import GUI in "%oot/lib/GUI"
var iWindow : int := Window.Open ("noecho, offscreenonly")

const cDropCount := 100
type point :
    record
        x : int
        y : int
    end record
randomize
var iSpeed : int := 10
var aiDrops : array 1 .. cDropCount of point
var iX, iY, iButton : int

procedure DrawDrop (x, y : int)
    drawfillbox (x, y, x + 1, y + 5, 77)
    drawfillbox (x - 1, y + 1, x + 2, y + 3, 77)
end DrawDrop

mousewhere (iX, iY, iButton)
var iDir : int := iX - maxx div 2
for i : 1 .. cDropCount
    if iDir > 0 then
        randint (aiDrops (i).x, 1 - abs (iDir), 640)
    elsif iDir < 0 then
        randint (aiDrops (i).x, 1, 640 + abs (iDir))
    else
        randint (aiDrops (i).x, 1, 640)
    end if
    randint (aiDrops (i).y, 480, 480 * 2)
end for
RGB.SetColour (0, 0, 0, 0)

loop
    delay (10)
    Window.Update (iWindow)
    cls
    for i : 1 .. cDropCount
        if aiDrops (i).y < -5 then
            if iDir > 0 then
                randint (aiDrops (i).x, 1 - abs (iDir), 640)
            elsif iDir < 0 then
                randint (aiDrops (i).x, 1, 640 + abs (iDir))
            else
                randint (aiDrops (i).x, 1, 640)
            end if
            randint (aiDrops (i).y, 480, 490)
        else
            mousewhere (iX, iY, iButton)
            iDir := iX - maxx div 2
            aiDrops (i).x += iDir div 50
            aiDrops (i).y -= iSpeed
        end if
        DrawDrop (aiDrops (i).x, aiDrops (i).y)
    end for
    exit when buttonmoved ("down")
end loop
Window.Close (iWindow)

Author:  zomg [ Tue Nov 30, 2004 10:44 am ]
Post subject: 

i kinda like the first one it may not look like real rain but for some reason i like the effect:)

Author:  the_short1 [ Wed Dec 01, 2004 4:56 pm ]
Post subject: 

Rapscallion... u The King ... ncie stuff.... kidna like the good snowflake ones by mazer and asian...

Author:  MihaiG [ Wed Dec 01, 2004 6:49 pm ]
Post subject: 

code:

var n, font2, clr : int
n := 1000
var x, y, l, cl : array 1 .. n of int
for i : 1 .. n
    randint (clr , 1, 255)
end for
font2 := Font.New ("sans serif:20:bold,italic,underline")
assert font2 > 0
Font.Draw ("Are you happy Tony?", 50, 80, font2, clr)
Font.Free (font2)
for i : 1 .. n
    randint (cl (i), 1, 255)
    randint (l (i), 1, 5)
    randint (x (i), 1, maxx - l (i))
    randint (y (i), l (i), maxy)
end for
loop
    for i : 1 .. n
        if y (i) < maxy - l (i) then
            drawline (x (i), y (i), x (i), y (i) + l (i), white)
        else
            drawline (x (i), maxy, x (i), y (i), white)
        end if

        if y (i) <= l (i) then
            randint (x (i), 1, maxx)
            y (i) := maxy
        else
            y (i) := y (i) - 8 %l (i)
        end if
        drawline (x (i), y (i) + l (i), x (i), y (i), cl (i))
    end for
end loop
there you go tony are you happy??? i have fixed ur probs../.. so mayn sleepless nights Wink

Author:  Cervantes [ Wed Dec 01, 2004 7:07 pm ]
Post subject: 

True, it can sometimes rain / snow unusual colours such as pink, but so many different colours of rain at one time? Are you mad?! Laughing
Have a bit for creativity and determination. Wink

Author:  MihaiG [ Wed Dec 01, 2004 7:29 pm ]
Post subject: 

yes Geoff but if you read before tony wrote that he wanted different colours Wink and i did that... he also wanted them to be the same speed...i tried making a background colour but it would cause seizures Wink

Author:  Tony [ Wed Dec 01, 2004 7:36 pm ]
Post subject: 

ahh, its acid rain! Surprised
try
code:
    randint (cl (i), 51, 56)


and place a background colour in there... find a way to not cause seizures Confused

and I think your droplets are falling in same plane again..

Author:  MihaiG [ Wed Dec 01, 2004 8:13 pm ]
Post subject: 

do you have something against planes? are you discriminating against planes i don't tolereate de-planers in my post Wink

-edit-


the multi colour version reminds me of confeti(party thinga-majigers)

anyhting else?? tony

Author:  omar [ Thu Dec 02, 2004 9:34 am ]
Post subject: 

the third program is the most realistic

Author:  BPhelmet [ Sun Dec 19, 2004 10:52 pm ]
Post subject: 

it's cool

but the rain drops are moving really fast


: