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

Username:   Password: 
 RegisterRegister   
 [Source]SnowFlake Program (Mouse)
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Delta




PostPosted: Tue Apr 27, 2004 11:56 am   Post subject: [Source]SnowFlake Program (Mouse)

Here is the snowflake program that reacts to the movement of the mouse in the [x] direction. Its not great because I'm being rushed but whatever it'll do for now. If the program runs too slow on your computer change the variable fCount to something smaller (not too small otherwise the program looks like crap).

code:
% Blizzard dependant upon the mouse movement/placement
View.Set ("offscreenonly,nobuttonbar")

type flakes :
    record
        x : int % [x] position
        y : int % [y] position
        dX : int % Direction [x]
        size : int % Size of snow flake [1,2, or 3]
    end record

var fCount : int := 800 % Change to set the number of snowflakes
var mX, mY, mB : int := 0 % Mouse Coordinates
var snow : array 1 .. fCount of flakes % Create the snowflakes

procedure RandomizeValues (count : int)
    snow (count).x := Rand.Int (-300, maxx + 300) % Randomize the position [x]
    snow (count).y := Rand.Int (maxy, maxy + 200) % Randomize the position [y]
    snow (count).size := Rand.Int (1, 3) % Randomize the size of the snowflake
    snow (count).dX := Rand.Int (-3,3) % Randomize the direction of the snowflake
end RandomizeValues

% Initialize values
for i : 1 .. fCount
    RandomizeValues (i) % Randomize the values for each snow flake
end for

loop
    Draw.FillBox (0, 0, maxx, maxy, 7)
    for i : 1 .. fCount
        Mouse.Where (mX, mY, mB)
        snow (i).x += snow (i).dX + (mX - maxx div 2) div 150 * snow (i).size % Move the snowflake in its [x] direction
        snow (i).y -= snow (i).size*2 % Move the snowflake downward
        Draw.FillOval (snow (i).x, snow (i).y, snow (i).size, snow (i).size, 25+snow(i).size*2) % Draw the snow flake
        if snow (i).y < 0 then % If the snowflake has reached the ground
            RandomizeValues (i) % Start it over
        end if
    end for
    View.Update
end loop
Sponsor
Sponsor
Sponsor
sponsor
Flashkicks




PostPosted: Tue Apr 27, 2004 12:12 pm   Post subject: (No subject)

Thats nice;) Indeed!!.. But now i have no challenge ahead of me:( Confused
Paul




PostPosted: Tue Apr 27, 2004 2:20 pm   Post subject: (No subject)

lol very cool, so many snow programs...
I like this one the best Laughing
we64




PostPosted: Wed Apr 28, 2004 12:31 pm   Post subject: (No subject)

cool program..... didn't understand the code....
Delta




PostPosted: Wed Apr 28, 2004 3:21 pm   Post subject: (No subject)

Have you read the comments? because if you haven't maybe that'll help you... I'm pretty sure I commented most of the lines... but ya...
MyPistolsIn3D




PostPosted: Thu Apr 29, 2004 1:20 pm   Post subject: snow

Would it be possible to like have other stuff going on while this is in the background? like a menu screen or sumthing like that?
Canadian Rob




PostPosted: Thu May 20, 2004 8:55 pm   Post subject: (No subject)

cool
the_short1




PostPosted: Mon May 24, 2004 6:41 pm   Post subject: (No subject)

wow delta... lookz nice.. diferent sizes of snow and all..
suggestion: make them stars isnetad of ovals..

yea i want to make a snowflake program too....
just laking the will power...
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 1  [ 8 Posts ]
Jump to:   


Style:  
Search: