Computer Science Canada Keeping Some Numbers, But Not Others |
Author: | SwAnK [ Sun Apr 24, 2005 11:35 pm ] | ||
Post subject: | 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.??
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! |
Author: | shlitiouse [ Mon Apr 25, 2005 1:49 am ] | ||
Post subject: | |||
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
Alright, this is quite a bit different than what you were doing. But what I've done here is that I used 3 dice, just to keep things clear. 3 boxes will be drawn on the screen, you can label them or whatever hower you want, when they're clicked then their variable is set to "selected" and it then asks if the user is sure that they want to reroll those dice. It then goes into a series of if/elsif to re-roll each of the dice who's variable is set to "selected". I haven't run this through turing, so it's all been entered off the top of my head, but in theory when I run it through my head it should work. It's not the most basic way to do it, though I find this nice because it allows for more interactivity with the mouse. |