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

Username:   Password: 
 RegisterRegister   
 [Source] Snow
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
AsianSensation




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
white_dragon




PostPosted: Thu Mar 11, 2004 4:24 pm   Post subject: (No subject)

nice.
Paul




PostPosted: Thu Mar 11, 2004 4:48 pm   Post subject: (No subject)

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




PostPosted: Thu Mar 11, 2004 4:56 pm   Post subject: (No 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...
Tony




PostPosted: Thu Mar 11, 2004 7:27 pm   Post subject: (No subject)

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

AsianSensation is a mod, his bits are a static 1000
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
AsianSensation




PostPosted: Thu Mar 11, 2004 7:53 pm   Post subject: (No 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.
WhatAmIDoing




PostPosted: Fri Apr 02, 2004 11:15 am   Post subject: (No subject)

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




PostPosted: Mon Apr 05, 2004 11:19 am   Post subject: (No subject)

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




PostPosted: Mon Apr 12, 2004 1:17 am   Post subject: (No 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
the_short1




PostPosted: Mon Apr 12, 2004 2:28 am   Post subject: (No 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....
RaPsCaLLioN




PostPosted: Mon Apr 12, 2004 2:54 am   Post subject: (No subject)

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




PostPosted: Thu Apr 29, 2004 3:48 pm   Post subject: (No subject)

why always the last Update got problems? whats wrong?
the_short1




PostPosted: Thu Apr 29, 2004 6:10 pm   Post subject: (No 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
Raugrist




PostPosted: Fri Apr 30, 2004 4:49 am   Post subject: (No subject)

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




PostPosted: Wed Jan 03, 2007 11:10 pm   Post subject: (No 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?
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  [ 18 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: