
-----------------------------------
SwAnK
Sun Apr 24, 2005 11:35 pm

Keeping Some Numbers, But Not Others
-----------------------------------
hey, I'm trying to get my dice program, so that when you roll, you can select what dice you wish to keep and which you'd like to roll again. 
Here is my code so far. I'm confused about how I can get which dice the user would like to keep. Each of the Rand.Int are already assigned values are they not, in my code, 1..5.??

var roll : array 1 .. 5 of int
var reroll : int
var dice : int

procedure rolling
    for i : 1 .. 5
        roll (i) := Rand.Int (1, 6)
        put "Rolled ", roll (i)
    end for
end rolling


rolling
put "how many dice do you want to reroll"
get reroll
put "what dice do u want to reroll?"
get WHAT DO I PUT HERE???????

for i : 1 .. reroll
    roll (i) := Rand.Int (1, 6)
    put "Rolled", roll (i)
end for

oh, and also it would be cool, so that when they rerolled the dice the orginal dice rolled, actually rerolled. For mine it would display the numbers, then show the rerolls seprately. if you get rid of the one get you'd see what i mean. Thanx again!

-----------------------------------
shlitiouse
Mon Apr 25, 2005 1:49 am


-----------------------------------
Hmmm, I haven't really used arrays at all, but I've read a basic tutorial on them, so I'm not completely lost here... First off, there's a couple ways that you could do this.

var a:string
var dice1,dice2,dice3:string:="not"
var dicenum1.dicenum2.dicenum3 %for purposes of this example, I'll just do this as if there's only 3 dice being rolled


loop
   dice1:="not"
   dice2:="not"%setting all dice variables to an off position
   dice3:="not"
       for i : 1 ..3 
           randint(num,1,6)
           put "Rolled ", roll (i)
           if i=1 then %counts what dice is being rolled and stores the                  variable into the dicenum variable.
              dicenum1=num
           elsif i=2 then 
              dicenum2=num
           elsif i=3 then 
              dicenum3=num
           end if
       end for


   drawbox (10,10,20,20,black)
   drawbox (25,25,35,35,black)%these are the buttons representing the   dice
   drawbox (40,40,50,50,black)
   put "how many dice do you want to reroll"
   get reroll
   if reroll>0 then
      put "what dice do u want to reroll?"
     loop  
        mousewhere(mx,my,b)
%these lines make it so that if a button is clicked while over on of the mouse buttons, then it will change that dice's variable to "selected"
        if b=1 mx>=10 and mx =10 and my=25 and mx=25 and my=40 and mx=40 and my