In a tetris game, I am just preparing it. I made an unsigned int for the score. I want to know how I would display the amount of "score" into a message box or Dialog. Preferably Message. Thanks.
In a tetris game, I am just preparing it. I made an unsigned int for the score. I want to know how I would display the amount of "score" into a message box or Dialog. Preferably Message. Thanks.
Language: C++
Compiler: Visual C++ 6.0
Currently Working On: Simple OpenGL aspects
Perhaps you could do something like this:
unsigned int value;
char string [80];
// Create a string
sprintf (string "Value is %d\n", value);
// Print the string
AfxMessageBox (string);
Hmm... I am doing it in C++. That looks like C... I tried doing it like this:
But it didn't work..Code:MessageBox (NULL, " #1: "<<score<<"", "Scores", MB_OK);
Language: C++
Compiler: Visual C++ 6.0
Currently Working On: Simple OpenGL aspects
You cannot utilize this functionality "<<" in your MessageBox. This is a stream class overload type thingy, and so you must use traditional C syntax. No worries, though. C++ IS C!
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Ok, then im not good with C. How would i display the score in my Message Box then? Here is what i have so far for it:
(note: just snippets)
Code:unsigned int score = 0; char string [80]; //and below.... case IDC_BUTTON4: MessageBox(NULL, " #1 - \n #2 - \n #3 -", "Hi-Scores", MB_OK); break;
Language: C++
Compiler: Visual C++ 6.0
Currently Working On: Simple OpenGL aspects
You might do:
sprintf(buff, " The High Score Is %i", score);
Then MessageBox buff...
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Clarification:
You don't use the sprintf() to print out the result on the screen, just converting the int into a string.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Just create one string and output it.
CString sScore;
sScore.Format("High Score: %d", m_highScore);
AfxMessageBox(sScore);
Or for those of us who detest MFC:
Code:char messageBuffer[WHATEVER_SIZE]; snprintf(messageBuffer, sizeof(messageBuffer), "High Score: %d", m_highScore); MessageBox(hWnd, messageBuffer, "Score", MB_OK);
Quidquid latine dictum sit, altum sonatur.
Whatever is said in Latin sounds profound.