Computer Science Canada

the dropping snow

Author:  appling [ Sat Nov 15, 2003 3:31 pm ]
Post subject:  the dropping snow

how could i make the snow drop form the top.and the randint must be used. the snow i made is very messy. it only randint all over the screen.

code:
drawfillbox (1, 1, maxx, maxy, 1)
var x, y : int
for i : 1 .. 50
    randint (x, 0, maxx)
    randint (y, 0, maxy)
    drawfilloval (x, y, 3, 3, 0)
    delay (200)
end for


how could i do???

Author:  AsianSensation [ Sat Nov 15, 2003 3:45 pm ]
Post subject: 

Like This?

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


enjoy

Author:  appling [ Sat Nov 15, 2003 3:51 pm ]
Post subject: 

thanks fo ur helping

Author:  Tony [ Sat Nov 15, 2003 3:55 pm ]
Post subject: 

Asian - that looks preaty good. You should repost the code in [Turing Source Code] section

Author:  Mazer [ Sat Nov 15, 2003 4:07 pm ]
Post subject: 

or this?

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)

Author:  AsianSensation [ Sat Nov 15, 2003 4:16 pm ]
Post subject: 

nice Mazer, that's cool, outthought me by one more dimension, lol

I had to admit, it was Mazer's idea in Evasive Maneuver helped me to make that code, I got it from the credits, where the stars go past the screen.

Author:  Mazer [ Sat Nov 15, 2003 4:34 pm ]
Post subject: 

lol, i love those credits! in fact.... i think i'll go watch them now. i keep forgetting who made that game!


: