Computer Science Canada Selecting a dice |
Author: | LEEEEROYJENKINS [ Wed Dec 14, 2011 9:52 am ] | ||
Post subject: | Selecting a dice | ||
What is the problem? I can't find the correct way to select a die and keep the face value of the die Describe what you have tried to solve this problem I have tried every possible combination of variables I can think of but I don't know how to get it to run here is my code the procedure "Keep" I know is unfinished this is the procedure I am trying to get to select the dice and keep the face value. Thanks!
|
Author: | Dreadnought [ Wed Dec 14, 2011 3:33 pm ] | ||
Post subject: | Re: Selecting a dice | ||
Ok, I think I didn't really understand what you were asking last time, but now I do (I think). So you have an array of dice values that is continuously changing. You want to stop one of the dice from changing and keep the others going. So you need some other array, to keep track of which dice to change and which not to change. Am array of Boolean values might do nicely. Then you'll need to check before randomizing each die whether of not the die should be changed. Here's an example (it's very primitive but should suffice to illustrate)
|
Author: | Velocity [ Wed Dec 14, 2011 8:43 pm ] |
Post subject: | RE:Selecting a dice |
var arrow : array char of boolean Input.KeyDown (arrow) if arrow (KEY_LEFT_ARROW) then %dice procedure on the left end if if arrow (KEY_RIGHT_ARROW) then % procedure on the right end if thats the use of right and left arrows and how you would use them, work from there :O |
Author: | LEEEEROYJENKINS [ Thu Dec 15, 2011 9:45 am ] |
Post subject: | Re: Selecting a dice |
I have tried to use the code you gave me (dreadnaught) but I think we have a misconception I am trying to randomize the face value of the dice (simulate a roll) the user then selects a dice he/she wants to keep then rolls the other two and so on until they get 3 of a kind, a pair etc. While this is going on I must keep a running tally to display it in a "Score" chart. The reply posted about moving something around to select the die works. I know I need another array to store my numbers. I just don't know how to do it properly. Apologies if I am frustrating this is my first year of programing. Thanks! |
Author: | LEEEEROYJENKINS [ Thu Dec 15, 2011 10:03 am ] |
Post subject: | Re: Selecting a dice |
Ok, I have the dice rolling but they always have 7 dots on them. No matter how many times I roll. I haven't even made a procedure to make 7 on the dice. Here is my code.. |
Author: | Dreadnought [ Thu Dec 15, 2011 9:28 pm ] | ||
Post subject: | Re: Selecting a dice | ||
For the 7 dots, your "rolling" procedure seems to be the problem. It has a loop that does not exit (or does not exit when it should). As for my example, I agree it was probably not the greatest. What I was trying to show was a way of choosing to not randomize some values in an array. Here's a (hopefully) better version.
As you can probably see, you don't need an extra array to store the numbers. We know which dice are not randomized and if we don't randomize them, then they store the value of that die. So on each roll you just have to count up the values of the dice that are not randomized to find out what the score is. I hope this makes sense. |
Author: | LEEEEROYJENKINS [ Fri Dec 16, 2011 9:21 am ] |
Post subject: | Re: Selecting a dice |
My dice still keep showing up as seven, I am at a dead end here :\. My die will randomly roll, stay at random for a split second then put seven dots on my dice ( I don't even have a seventh dot programed.) You guys are helping me out a lot, thanks for that, But it's like I am taking 1 step forward and 2 steps back with this program. Could you please explain to me how to get these dice to "Roll", be given a random number, and stop. Thanks, again |
Author: | LEEEEROYJENKINS [ Fri Dec 16, 2011 9:38 am ] |
Post subject: | Re: Selecting a dice |
UPDATE! I got the dice too work, now I just need help figuring out how to select them I am using the Input.Keydown method but my box that's suppose to highlight the dice and select it does not show up. |
Author: | Dreadnought [ Fri Dec 16, 2011 5:13 pm ] |
Post subject: | Re: Selecting a dice |
Just from looking at the last code you posted, does your "rolling" procedure ever exit or finish? |
Author: | LEEEEROYJENKINS [ Mon Dec 19, 2011 9:28 am ] |
Post subject: | Re: Selecting a dice |
Oh it finishes, I have no Idea how, I think the delay ends then the loop exits and that's when it stops. |