Computer Science Canada

help with a yahtzee game

Author:  nuno_owns [ Thu Jun 15, 2006 1:50 pm ]
Post subject:  help with a yahtzee game

my problem is that I can not get the dice to roll with the corresponding pictures. This is what I have now but it does not work.After my if statements at value it says "if must be boolean type".

code:

procedure Dice
    randomize
    for dice_1 (1 , 6)
        if value := 1 then
            Pic.Draw (picDice1, 5, 18, picCopy)
        elsif value := 2 then
            Pic.Draw (picDice2, 5, 18, picCopy)
        elsif value := 3 then
            Pic.Draw (picDice3, 5, 18, picCopy)
        elsif value := 4 then
            Pic.Draw (picDice4, 5, 18, picCopy)
        elsif value := 5 then
            Pic.Draw (picDice5, 5, 18, picCopy)
        elsif value := 6 then
            Pic.Draw (picDice6, 5, 18, picCopy)
        end if
    end for
end Dice


Thanks for all your help![/code]

Author:  jamonathin [ Thu Jun 15, 2006 2:11 pm ]
Post subject: 

Well first of all for loops aren't written like
You wrote:

for dice_1 (1 , 6)

but like . .
code:

for i: 1 .. 6


And secondly, we are comparing the values, not setting the values, so we dont use:
You wrote:

if value := 1 then

but rather . .
code:

if value = 1 then

The " := " is for setting a value, not comparing.

Author:  neufelni [ Thu Jun 15, 2006 2:12 pm ]
Post subject: 

Your problem is that you are using :=. This is used in Turing to assign values to variables. For if statements you want to just use =.


: