Computer Science Canada

DICE - it works

Author:  iceman [ Wed Nov 14, 2007 3:27 pm ]
Post subject:  DICE - it works

Thanks for your help!

code:


% The Visual Dice Program with Random seed


% declaration of variables

var dicePics : array 1 .. 6 of int

dicePics(1) := Pic.FileNew ("1dice.bmp")
dicePics(2) := Pic.FileNew ("2dice.bmp")
dicePics(3) := Pic.FileNew ("3dice.bmp")
dicePics(4) := Pic.FileNew ("4dice.bmp")
dicePics(5) := Pic.FileNew ("5dice.bmp")
dicePics(6) := Pic.FileNew ("6dice.bmp")

var die1,die2:int



% generate random seed for each die

die1 := Rand.Int(1, 6)
die2 := Rand.Int(1, 6)



% Pic.SetTransparentColor (pic, brightred)

setscreen ("graphics:768;512")
setscreen ("offscreenonly")




% this loop displays the random dice using the dicePics 1-D array

for x : 100 .. 500
    cls
    Pic.Draw(dicePics(die1), x, 100, picMerge)
    Pic.Draw(dicePics(die2), x, 250, picMerge)
    put die1,die2
    View.Update
    delay (1)
end for


Author:  Mazer [ Wed Nov 14, 2007 3:41 pm ]
Post subject:  RE:DICE - it works

...


: