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

Recommended Answers

All 11 Replies

I thinking of a number between 223 and 367 -- what is it?

[Translation -- do you think you could be a little more specific?]

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?

Are you doing some sort of graphics stuff, or does this relate to the standard C or C++ languages?

A start for windows. Modify to your requirements.Further Reference

#include <iostream>
#include <windows.h>
int main()
{
    DWORD dwWritten;
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO  ConsoleScreenBufferInfo;

    GetConsoleScreenBufferInfo(hConsole, &ConsoleScreenBufferInfo);
    COORD coordCurrent = ConsoleScreenBufferInfo.dwCursorPosition;
    for ( int j = 0  ; j < 10  ; j++ )
    {
	FillConsoleOutputCharacter(hConsole, j + toascii('0'), 1, coordCurrent, &dwWritten);
	coordCurrent.X++;
	FillConsoleOutputCharacter(hConsole, toascii('9') - j  , 1, coordCurrent, &dwWritten);
	Sleep( 100 );
	coordCurrent.X--;
    }
    coordCurrent.X += 2;
    SetConsoleCursorPosition( hConsole,coordCurrent );
    std::cin.ignore();
    return 0;
}

No graphics, just plain standard C++.

Output the line of text. Then output a carriage return '\r' . This may or may not let you start overwriting the same line.

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???

#include <iostream>
using namespace std;

int main()
{
   for ( ;; )
   {
      cout << "\r 1 2 3";
      cout << "\r 4 5 6";
      cout << "\r 7 8 9";
   }
   return 0;
}

That's pretty cool. Thanks Dave. How about font size for output... how do you change it to a bigger font?

Leave standard C++ and learn a graphics library.

What exactly does the code do that Wolfpack submitted?

It spins some characters. However Iam for the simpler method from Dave.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.