Beispiel #1
0
int main()
{
    BOOL	bSuccess;
    int     i;
    char	szBuf[30];

    InitConsoleIO();        // must call this at startup

    ClrScr();              // clear the screen

    for ( i=0; i < 20; i += 2 ) {
		// QUESTION H what does the next line do?
        GotoXY(i,i);   
		// make a message and put it out
        sprintf( szBuf, "%d,%d", i, 2*i );
        bSuccess = PutText(szBuf);  // test PutText.
        if (!bSuccess) 
            printf("WriteConsoleOutputCharacter error\n"); 
    }

	// make some cool messages in different colours
    TextColour( BC_RED );
    TextBackground( BC_GREEN );
    Cprintf("Cool %d ", i++);

    TextColour( BC_BLACK );
    TextBackground( BC_LIGHTGRAY );
    Cprintf("colours %d ", i++);

    TextColour( BC_LIGHTMAGENTA );
    TextBackground( BC_BLUE );
    Cprintf(" Eh %d?", i);

    return(1);
}
Beispiel #2
0
void Game::DisplayScore(wxDC& dc)
{
    wxColour bgColour = BackgroundColour();
    wxPen* pen = wxThePenList->FindOrCreatePen(bgColour, 1, wxSOLID);
    dc.SetTextBackground(bgColour);
    dc.SetTextForeground(TextColour());
    dc.SetBrush(BackgroundBrush());
    dc.SetPen(* pen);

    // count the number of cards in foundations
    m_currentScore = 0;
    for (int i = 0; i < 8; i++)
    {
        m_currentScore += m_foundations[i]->GetNumCards();
    }

    int x, y;
    m_pack->GetTopCardPos(x, y);
    x += 12 * CardWidth - 105;

    wxCoord w, h;
    {
        wxCoord width, height;
        dc.GetTextExtent(wxT("Average score:m_x"), &width, &height);
        w = width;
        h = height;
    }
    dc.DrawRectangle(x + w, y, 20, 4 * h);

    wxString str;
    str.Printf(wxT("%d"), m_currentScore);
    dc.DrawText(wxT("Score:"), x, y);
    dc.DrawText(str, x + w, y);
    y += h;

    str.Printf(wxT("%d"), m_numGames);
    dc.DrawText(wxT("Games played:"), x, y);
    dc.DrawText(str, x + w, y);
    y += h;

    str.Printf(wxT("%d"), m_numWins);
    dc.DrawText(wxT("Games won:"), x, y);
    dc.DrawText(str, x + w, y);
    y += h;

    int average = 0;
    if (m_numGames > 0)
    {
        average = (2 * (m_currentScore + m_totalScore) + m_numGames ) / (2 * m_numGames);
    }
    str.Printf(wxT("%d"), average);
    dc.DrawText(wxT("Average score:"), x, y);
    dc.DrawText(str, x + w, y);
}
Beispiel #3
0
void Pack::Redraw(wxDC& dc)
{
    Pile::Redraw(dc);

    wxString str;
    str.Printf(wxT("%d  "), m_topCard + 1);

    dc.SetBackgroundMode( wxSOLID );
    dc.SetTextBackground(BackgroundColour());
    dc.SetTextForeground(TextColour());
    dc.DrawText(str, m_x + CardWidth + 5, m_y + CardHeight / 2);

}