![]() |
|
#1
|
|||
|
|||
roll dice animationHello!
i have to write code for a dice roll by displaying the numbers 1 to 6 on the screen.. This is what i have done: CPP / C++ / C Code:
Last edited by LuciWiz : 06-Apr-2008 at 12:05.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|||
|
#2
|
||||
|
||||
Re: roll dice animationI see 2 problems here.
1. CPP / C++ / C Code:
Should be CPP / C++ / C Code:
Why? Because it's possible (although unlikely in this case since the body of the loop is so small) that we could skip right past the point where time(0) == later. Again, it's very unlikely that this will cause problems with your program, but it's important to understand the principle. 2. I'm assuming that you don't want to display the results until after the time has passed. That means that you should do it after the while loop terminates: CPP / C++ / C Code:
__________________
www.blake-foster.com |
|
#3
|
|||
|
|||
Re: roll dice animationQuote:
CPP / C++ / C Code:
Quote:
Since the function name is "Anim...," I would assume that some kind of animation is involved. See Footnote. Maybe: CPP / C++ / C Code:
If the terminal implementation supports a "backspace" character, this might give what was wanted. I mean, the '\b' special character is part of the C language standard, but not all terminals support it, so the actual action is implementation (and hardware) dependent. In other words: IWFMYMMV (It Works For Me---Your Mileage May Vary.) Regards, Dave Footnote: Since the Original Poster didn't actually mention what was meant by "doesn't work," we are both guessing. Maybe I'm wrong. To Original Poster: It might save some time and bandwidth if you would actually tell us 1. What did you expect to happen (or what did you want to happen). 2. What happened? 3. What do you not understand about the difference between 1 and 2. I mean, why should we have to guess? Final comment: The singular of "dice" is "die." If you have one, it's a "die." If you have two (or more), they are "dice." |
|
#4
|
|||
|
|||
Re: roll dice animationwell when i use the function as
x=AnimOfDice(); it works.. but when i use it in a loop for(i=0;i<4;i++) i get lots of numbers... i need to display the dice roll for 4 players |
|
#5
|
|||
|
|||
Re: roll dice animationQuote:
Well, "getting lots of numbers" doesn't really tell us much. Or maybe it's just me. I'm not going to guess again. I respectfully suggest that you show us the code. Then (and I hate to repeat myself) but: 1. Tell us what you expected to happen. 2. Tell us what happened. 3. Tell us what you don't understand about the difference between 1 and 2 Regards, Dave |
Recent GIDBlog
Install Adobe Flash - Without Administrator Rights by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with Dice program | killzone | C++ Forum | 5 | 22-Nov-2006 11:15 |
| Decks and Dice | cable_guy_67 | C++ Forum | 12 | 19-May-2006 09:43 |
| Dice rolling program (random number generator) | crystalattice | Python Forum | 1 | 17-Apr-2006 17:34 |
| Possible Use of an Array???? | Nexa | C++ Forum | 6 | 29-Nov-2004 19:49 |
| problems with animation | blelisa | Graphics Forum | 4 | 05-Mar-2004 07:08 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The