C++ Slot machine

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2005
Posts: 5
Reputation: mtodd51 is an unknown quantity at this point 
Solved Threads: 0
mtodd51 mtodd51 is offline Offline
Newbie Poster

C++ Slot machine

 
0
  #1
Nov 18th, 2005
I just finished a simple slot machine program. It displays 3 random numbers from 0 - 9 next to each other. I'd like to "soup" it up. Is there some way I can make each of the the numbers spin and stop sequentially. thanks
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: C++ Slot machine

 
0
  #2
Nov 19th, 2005
I thinking of a number between 223 and 367 -- what is it?

[Translation -- do you think you could be a little more specific?]
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 5
Reputation: mtodd51 is an unknown quantity at this point 
Solved Threads: 0
mtodd51 mtodd51 is offline Offline
Newbie Poster

Re: C++ Slot machine

 
0
  #3
Nov 19th, 2005
When the numbers are output to the screen, I have them come up about .25" apart from each other horizontally. When they are displayed, can they be made to look like they spinning, and then the one on the left stops 1st, then the one in the middle stops spinning, then then the one on the right stops spinning? Get it?
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: C++ Slot machine

 
0
  #4
Nov 19th, 2005
Are you doing some sort of graphics stuff, or does this relate to the standard C or C++ languages?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: C++ Slot machine

 
0
  #5
Nov 19th, 2005
A start for windows. Modify to your requirements.Further Reference
  1. #include <iostream>
  2. #include <windows.h>
  3. int main()
  4. {
  5. DWORD dwWritten;
  6. HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  7. CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
  8.  
  9. GetConsoleScreenBufferInfo(hConsole, &ConsoleScreenBufferInfo);
  10. COORD coordCurrent = ConsoleScreenBufferInfo.dwCursorPosition;
  11. for ( int j = 0 ; j < 10 ; j++ )
  12. {
  13. FillConsoleOutputCharacter(hConsole, j + toascii('0'), 1, coordCurrent, &dwWritten);
  14. coordCurrent.X++;
  15. FillConsoleOutputCharacter(hConsole, toascii('9') - j , 1, coordCurrent, &dwWritten);
  16. Sleep( 100 );
  17. coordCurrent.X--;
  18. }
  19. coordCurrent.X += 2;
  20. SetConsoleCursorPosition( hConsole,coordCurrent );
  21. std::cin.ignore();
  22. return 0;
  23. }
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 5
Reputation: mtodd51 is an unknown quantity at this point 
Solved Threads: 0
mtodd51 mtodd51 is offline Offline
Newbie Poster

Re: C++ Slot machine

 
0
  #6
Nov 19th, 2005
No graphics, just plain standard C++.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: C++ Slot machine

 
0
  #7
Nov 19th, 2005
Output the line of text. Then output a carriage return '\r'. This may or may not let you start overwriting the same line.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 5
Reputation: mtodd51 is an unknown quantity at this point 
Solved Threads: 0
mtodd51 mtodd51 is offline Offline
Newbie Poster

Re: C++ Slot machine

 
0
  #8
Nov 19th, 2005
dave, I'm totally confused. Did I mention I was a newbie to C++?. What exactly does the code do that Wolfpack submitted? And what did your response regarding the carriage return mean? Are we still talking about making output numbers appear to spin on the srceen???
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: C++ Slot machine

 
0
  #9
Nov 19th, 2005
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. for ( ;; )
  7. {
  8. cout << "\r 1 2 3";
  9. cout << "\r 4 5 6";
  10. cout << "\r 7 8 9";
  11. }
  12. return 0;
  13. }
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 5
Reputation: mtodd51 is an unknown quantity at this point 
Solved Threads: 0
mtodd51 mtodd51 is offline Offline
Newbie Poster

Re: C++ Slot machine

 
0
  #10
Nov 19th, 2005
That's pretty cool. Thanks Dave. How about font size for output... how do you change it to a bigger font?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC