Computer Science Canada

Falling Snow

Author:  Turing_Student [ Tue Dec 03, 2002 11:27 pm ]
Post subject:  Falling Snow

Hey, how are you all doing?
I'm a h/s student and I'm just trying to get thru my computer science class Wink Haha, so for my final project we have to make a computer game and I'm having trouble with making snow fall down my screen. I know it's probably very simple, but I have no clue how to make it work. I know how the Rand.Int function works but is that the way to go? If anyone could help me with this that would be great! Thanks!

Author:  Tony [ Tue Dec 03, 2002 11:54 pm ]
Post subject: 

there're few ways of doing that, it depends on the result you want to achive. The easiest is

proc Snow(amount:int)
for i:1..amount
x:= Rand.Int(1,maxx)
y:= Rand.Int(1,maxy)
end for
end Snow

Here you basically randomly pick location for the snowflake and draw it there. But it will be different every time you do that, since its random.

To make snow actually fall, you'd have to create an array, storing their location and making it "fall" (y:=y-1) each time you go through the loop. As in


for i:1..SnowAmount
snowY(i):= snowY(i) - 1
end for

Good luck on your project Exclamation

Author:  Turing_Student [ Tue Dec 03, 2002 11:57 pm ]
Post subject:  Thanks!

Wow, thanks so much! I'll let ya know if I can get it working! Very Happy