Billy's Snow
Author |
Message |
Flashkicks
|
Posted: Mon Apr 26, 2004 10:49 am Post subject: Billy's Snow |
|
|
This is a program I made with some help via Delta and ideas from other Compsci Members.. It is just snow falling down- However; you can click with the mouse to change its direction.. I wanted it to be so that the direction FOLLOWS the direction of the mouse. [Scroll the mouse to the FAR LEFT- and the snow will blow really hard to the left--scroll it slightly past the centre to the right, and the snow would blow calmly to the right..etc] buuuuut I am unfortunately not very good with detecting the mouse locations like this..
code: | View.Set ("offscreenonly")
var mx, my, mb : int
var change : boolean := false
var click : int := 0
type snowDrop :
record
x : int
y : int
size : int
spd : int
dx : int
end record
var snow : array 1 .. 100 of snowDrop
for i : 1 .. 100
snow (i).x := Rand.Int (0, maxx)
snow (i).y := Rand.Int (maxy, maxy + 100)
snow (i).size := Rand.Int (1, 3)
snow (i).spd := -1 - snow (i).size
snow (i).dx := Rand.Int (-2-snow(i).size, 2+snow(i).size)
end for
loop
mousewhere (mx, my, mb)
cls
drawfillbox (0, 0, maxx, maxy, 7)
if mb = 0 and change = true then
change := false
elsif mb = 1 and change = false then
change := true
if click = 1 then
click := 2
elsif click = 2 then
click := 3
elsif click = 3 then
click := 1
else
click := 1
end if
for i : 1 .. 100
if click = 1 then
snow (i).dx := 2 + snow(i).size
elsif click = 2 then
snow (i).dx := -2 - snow(i).size
elsif click = 3 then
snow (i).dx := Rand.Int (-2-snow(i).size, 2+snow(i).size)
end if
end for
end if
for i : 1 .. 100
drawfilloval (snow (i).x, snow (i).y, snow (i).size, snow (i).size, 7)
snow (i).x += snow (i).dx
snow (i).y += snow (i).spd
drawfilloval (snow (i).x, snow (i).y, snow (i).size, snow (i).size, 0)
if snow (i).y <= 0 then
snow (i).x := Rand.Int (0, maxx)
snow (i).y := Rand.Int (maxy, maxy + 100)
snow (i).size := Rand.Int (1, 3)
snow (i).spd := -1 - snow (i).size
% snow (i).dx := Rand.Int (-5, 5)
end if
if snow (i).x <= 0 then
snow (i).x := maxx - 5
elsif snow (i).x >= maxx then
snow (i).x := 5
end if
end for
View.Update
end loop
|
Enjoy! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Raugrist
|
Posted: Mon Apr 26, 2004 11:26 am Post subject: (No subject) |
|
|
Yeah, I noticed that moving the mouse actually doesn't affect the direction the snow blows in. In fact, the directions don't change until you click the mouse, and even then it doesn't matter where the mouse is. All you programmed it to do was cycle between 3 different possible ways of falling when you click the mouse. You can actually check the mouse x coordinate (mx) with relation to the middle of the screen (maxx div 2) to decide how fast the snow moves along the x axis.
That is, get (mx - maxx div 2) for the speed and just add that to each snowflakes x coordinate.
EDIT: well, something like that. Maybe just a percentage of (mx - maxx div 2) so it doesn't go insanely fast when you move away from the middle. So use (mx - maxx div 2) div 40 or something.
Or try this line, so that the snowflakes in the back move a little bit slower:
snow (i).x += round ((mx - maxx div 2) / 40 / (4 - snow (i).size)) |
|
|
|
|
|
Paul
|
Posted: Mon Apr 26, 2004 2:28 pm Post subject: (No subject) |
|
|
Am I the only one that found the first effect really really cool? |
|
|
|
|
|
Flashkicks
|
Posted: Mon Apr 26, 2004 6:57 pm Post subject: (No subject) |
|
|
Raugrist, I am pretty sure I stated that the mousewhere stuff is wut i WANTED to ADD in yet. but if I did not mention that- thwen i apologize- that is wut I had intentions of stating. Im sorry.. But other than that- thank you for the Code ideas.. I shall try it out nd show you how it turns out once it is done!! |
|
|
|
|
|
Mazer
|
Posted: Tue Apr 27, 2004 4:44 am Post subject: (No subject) |
|
|
He probably just missed it. Actually, the first time I read your post I missed it too, it looked like you were saying that was how your program worked instead of how you wanted it to work. |
|
|
|
|
|
|
|