Computer Science Canada

[Source] Snow

Author:  AsianSensation [ Wed Mar 10, 2004 10:53 pm ]
Post subject:  [Source] Snow

it seems alot of people have been as been wanting to do a snowfall program. Here are the three made by me, Mazer, and me in that order.

code:
View.Set ("offscreenonly")
colorback (blue)
cls

type SnowType :
    record
        X, Y, Spd, Size : int
    end record

var Snow : array 1 .. 100 of SnowType

for rep : 1 .. 100
    Snow (rep).X := Rand.Int (5, 645)
    Snow (rep).Y := Rand.Int (5, 475)
    Snow (rep).Spd := Rand.Int (1, 3)
    Snow (rep).Size := Snow (rep).Spd
end for

loop
    for rep : 1 .. 100
        Snow (rep).Y -= Snow (rep).Spd
        if Snow (rep).Y < Snow (rep).Size then
            Snow (rep).Y := Rand.Int (475, 575)
        end if
        drawfilloval (Snow (rep).X, Snow (rep).Y, Snow (rep).Size, Snow (rep).Size, white)
    end for
    View.Update
    cls
end loop



code:
var win := Window.Open ("graphics:600;400,nobuttonbar,offscreenonly")
colourback (7)

var snowx, snowy, velx, vely : array 1 .. 75 of int

for i : 1 .. 75
    snowx (i) := Rand.Int (0, maxx + 400)
    snowy (i) := Rand.Int (0, maxy)
    velx (i) := Rand.Int (2, 4)
end for

loop
    exit when hasch
    for i : 1 .. 75
        drawfilloval (snowx (i), snowy (i), velx (i) div 2, velx (i) div 2, 0)
        snowx (i) -= velx (i)
        snowy (i) -= 4

        if snowy (i) < 0 or snowx (i) < 0 then
            snowx (i) := Rand.Int (0, maxx + 400)
            snowy (i) := maxy
        end if
    end for
    View.Update
    delay (25)
    cls
end loop

Window.Close (win)


code:
View.Set ("offscreenonly")
colorback (black)
cls

var size : int := 200
var counter : real := 0
var t1 := Time.Elapsed
var d := 1

type SnowType :
    record
        X, Y, Spd, Size : real
    end record

var Snow : array 1 .. size of SnowType

for rep : 1 .. size
    Snow (rep).X := Rand.Int (0, maxx)
    Snow (rep).Y := Rand.Int (0, maxy)
    Snow (rep).Spd := Rand.Real * Rand.Int (1, 3)
    Snow (rep).Size := Snow (rep).Spd
end for

loop
    for rep : 1 .. size
        Snow (rep).Y -= Snow (rep).Spd
        Snow (rep).X += counter
        if Snow (rep).Y < 0 then
            Snow (rep).Y := Rand.Int (maxy, maxy + 100)
        end if
        if Snow (rep).X > maxx then
            Snow (rep).X := Rand.Int (-10, 0)
        end if
        if Snow (rep).X < 0 then
            Snow (rep).X := Rand.Int (maxx, maxx + 100)
        end if
        drawfilloval (round (Snow (rep).X), round (Snow (rep).Y), round (Snow (rep).Size), round (Snow (rep).Size), white)
    end for
    counter += d * 0.05

    if counter < 2 and counter > -2 then
        t1 := Time.Elapsed
    end if

    if (Time.Elapsed - t1) > 2000 and (counter >= 10 or counter <= -10) then
        d *= -1
        t1 := Time.Elapsed
    end if
    View.Update
    delay (5)
    cls
end loop

Author:  white_dragon [ Thu Mar 11, 2004 4:24 pm ]
Post subject: 

nice.

Author:  Paul [ Thu Mar 11, 2004 4:48 pm ]
Post subject: 

for the last program, how come it pauses for 1/3 of a second every 2 seconds on my screen?

Author:  guruguru [ Thu Mar 11, 2004 4:56 pm ]
Post subject: 

Umm... wow. That last one was quite impresssive Shocked (almost had a seizure lol). I would give you bits, but I already have barely any...

Author:  Tony [ Thu Mar 11, 2004 7:27 pm ]
Post subject: 

guruguru wrote:
I would give you bits, but I already have barely any...

AsianSensation is a mod, his bits are a static 1000

Author:  AsianSensation [ Thu Mar 11, 2004 7:53 pm ]
Post subject: 

Paul Bian wrote:
for the last program, how come it pauses for 1/3 of a second every 2 seconds on my screen?


don't get it? It works fine for me...maybe you are talking about something to do with delay? I did the switching positions thing with a timer, and I set it to switch blowing from one side to another every 2 secs.

Author:  WhatAmIDoing [ Fri Apr 02, 2004 11:15 am ]
Post subject: 

that is pretty good all though on the first one have the snow build up.

Author:  valor [ Mon Apr 05, 2004 11:19 am ]
Post subject: 

Razz nice i was just expecting some little flakes to fall down but i was wrong. the background moving was a nice touch

Author:  RaPsCaLLioN [ Mon Apr 12, 2004 1:17 am ]
Post subject: 

I'm bored.. minor improvement to first one...

code:
View.Set ("offscreenonly")
colorback (blue)
cls

type SnowType :
    record
        X, Y, Spd, Size : int
    end record

var Snow : array 1 .. 100 of SnowType

for rep : 1 .. 100
    Snow (rep).X := Rand.Int (5, 645)
    Snow (rep).Y := Rand.Int (5, 475)
    Snow (rep).Spd := Rand.Int (1, 6)
    Snow (rep).Size := Snow (rep).Spd
end for
var iCount : int := 0
loop
    delay (10)
    for rep : 1 .. 100
        Snow (rep).Y -= Snow (rep).Spd
        if Snow (rep).Y < Snow (rep).Size then
            Snow (rep).Y := Rand.Int (475, 575)
        end if
        if iCount = 4 then
            Snow (rep).X += Rand.Int (-1, 1)
        end if
        drawfillstar (Snow (rep).X, Snow (rep).Y, Snow (rep).X + Snow (rep).Size, Snow (rep).Y + Snow (rep).Size, white)
    end for
    if iCount = 4 then
        iCount := 0
    else
        iCount += 1
    end if
    View.Update
    cls
end loop

Author:  the_short1 [ Mon Apr 12, 2004 2:28 am ]
Post subject: 

... nice one rapscallion... size and speed diferences........ i havn;t seen u on... in what... years...you should check out my pac man game in FP contest forum...... i used ur 'following and attemp at colision' code in there for AI.... its pretty wicked....
NOTE: ur in credits....

Author:  RaPsCaLLioN [ Mon Apr 12, 2004 2:54 am ]
Post subject: 

cool.. i'll check it out, thx .. and as a side note.. the new Turing update blows

Author:  Prettyjnk [ Thu Apr 29, 2004 3:48 pm ]
Post subject: 

why always the last Update got problems? whats wrong?

Author:  the_short1 [ Thu Apr 29, 2004 6:10 pm ]
Post subject: 

hmm...... i dont know,,,, maybe Rapscallion dont like it because it cant do 'Add.Gradient' anymore like it used to...
meh...


the new update acually ROCKS... cuz without it... my pacman game would suck SOOOO bad...

Music.PlayFileLoop ("backroundbeat.mid")
Music.PlayFileReturn ("soundeffectdie.wav")

Both are only on turing 4.05

and both continue the program afta they start the music... therefore... no pause Wink



back to the snowfall program..
i thinking of making one... should i post here???
*** i will try to make the flakes build up on bottom of screen Smile

Author:  Raugrist [ Fri Apr 30, 2004 4:49 am ]
Post subject: 

the_short1, I think Prettyjnk was referring to the View.Update at the end. What version of turing are you running?

Author:  vertozia [ Wed Jan 03, 2007 11:10 pm ]
Post subject: 

hey there, i know this topic is old, but its general knowledge(i guess) that i dont know. How come when i draw pics on top of this amazing program, the program obscures my pics?

Author:  vertozia [ Wed Jan 03, 2007 11:29 pm ]
Post subject: 

I AM SORRY FOR DOUBLE POSTING, there is no edit button,
\
anyways there is my button, its for a main menu:

Quote:
%main


var mainPic, playPic, helpPic, highPic, makingPic, demoPic ,x, y, button: int
loop
mainPic := Pic.FileNew ("backgroundchick.jpg")
Pic.Draw (mainPic, 0,0, picCopy)


playPic := Pic.FileNew ("play.bmp")
Pic.Draw (playPic, 350, 350, picCopy)

helpPic := Pic.FileNew ("help.bmp")
Pic.Draw (helpPic, 350, 290, picCopy)

highPic := Pic.FileNew ("high.bmp")
Pic.Draw (highPic, 350, 230, picCopy)

makingPic := Pic.FileNew ("making.bmp")
Pic.Draw (makingPic, 350, 170, picCopy)

demoPic := Pic.FileNew ("demo.bmp")
Pic.Draw (demoPic, 350, 110, picCopy)
end loop


colorback (blue)
cls

type SnowType :
record
X, Y, Spd, Size : int
end record

var Snow : array 1 .. 100 of SnowType

for rep : 1 .. 100
Snow (rep).X := Rand.Int (5, 645)
Snow (rep).Y := Rand.Int (5, 475)
Snow (rep).Spd := Rand.Int (1, 3)
Snow (rep).Size := Snow (rep).Spd
end for

loop
for rep : 1 .. 100
Snow (rep).Y -= Snow (rep).Spd
if Snow (rep).Y < Snow (rep).Size then
Snow (rep).Y := Rand.Int (475, 575)
end if
drawfilloval (Snow (rep).X, Snow (rep).Y, Snow (rep).Size, Snow (rep).Size, white)
end for
View.Update
cls
end loop

Author:  ericfourfour [ Wed Jan 03, 2007 11:36 pm ]
Post subject: 

vertozia wrote:
there is no edit button

Wanna see magic? Look at the upper right hand corner of your post.

Author:  vertozia [ Thu Jan 04, 2007 12:04 am ]
Post subject: 

lmao how ironic, thanks for offering me help


: