1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
// Apologies for the "magic numbers" and ltoa and lack of TCHARs...
void DisplayPlayer(HDC hdc, const Player* pPlayer)
{
const char labelPlayer[] = "Player";
const char labelName [] = "Name";
const char labelLives [] = "Lives";
const COLORREF crefRed = RGB(255, 0, 0);
const COLORREF crefGreen = RGB( 0, 255, 0);
const COLORREF crefBlue = RGB( 0, 0, 255);
char displayTest[1024] = "";
COLORREF crefTextOld = SetTextColor(hdc, crefRed);
TextOut(hdc, 10, 10, labelPlayer, strlen(labelPlayer)); // evil "magic numbers"
SetTextColor(hdc, crefGreen);
TextOut(hdc, 10, 30, labelName, strlen(labelName));
SetTextColor(hdc, crefBlue);
const std::string& name = pPlayer->getName();
TextOut(hdc, 60, 30, name.c_str(), name.length());
SetTextColor(hdc, crefGreen);
TextOut(hdc, 10, 50, labelLives, strlen(labelLives));
SetTextColor(hdc, crefBlue);
char ageAsStr[16] = "";
ltoa(pPlayer->getLives(), ageAsStr, 10); // lazy demo code :-(
TextOut(hdc, 60, 50, ageAsStr, strlen(ageAsStr));
SetTextColor(hdc, crefTextOld);
}
|