Ok, i have a question about C++. for the final we are supposed to write a terminal program to play craps. (Casino game) I am not sure how i am going to make the dice animation, it was not needed. i just felt liek adding it. How could i make like a .3 second pause between each roll? Example in pseduo code


Code:

write the pic for 1 on a dice "*"
short pause
write the pic for 2 on a dice
short pause

etc.

i mostly just want it so it will cycle nicely. and the system("cls") wont make it jumpy i hope...

I could use for loops to determine speed of the pause, but that will change by system. I have a slower system and my teacher has a fast one. so not sure how well that would work.

also what would replace system("CLS") in linux? I know that is only the windows clear screen (if i understodd him right)
The way you are going to get your n millisecond pause is by checking the system time and while looping until it reaches a certain offset value from when you started looping.
^^ how would i do that? this is very limited C++ we can use so far. its only intro to comp sci. haha.
Check out the ctime (time.h) library.
ok thanks, will do.
Alternatively, the Sleep function might be a better way to do that.
To clear the terminal in Linux, look at http://stackoverflow.com/questions/1348563/clearing-output-of-a-terminal-program-linux-c-c
(Also, don't make us do your Googling for you Wink)
For linux, you can use usleep to sleep in microseconds (good enough for you). sleep will not work as it only sleeps in whole second increments only.

For CLS, the linux alternative is "clear". You should do a google search for "linux c++ terminal clear" to find out how to clear the terminal window when you roll.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement