How can I make a console in the game?

I was wondering how I could make a console in a game(full screen). To be specific in a game I'm making I have a ship and I'd like to be able to see the ships coordinates in the top right corner of the screen while the game runs.


Answer this question

How can I make a console in the game?

  • Linlin425872

    That did it, thanks.



  • Mikey0727

    Offbeat,

    I implemented something similar to this in a game to track various stats (framerate, position coords, etc). Listed below is the code that I used. You could wrap these functions in a class if you were doing some more complex statistics.

    In my object building routine:

    // font object creation
    D3DXFONT_DESC Descrip;
    ZeroMemory( &Descrip, sizeof(D3DXFONT_DESC) );
    _tcscpy( Descrip.FaceName, _T("Verdana") );

    Descrip.Height = 16;
    Descrip.Italic = false;
    Descrip.CharSet = DEFAULT_CHARSET;
    Descrip.OutputPrecision = OUT_DEFAULT_PRECIS;
    Descrip.Quality = NONANTIALIASED_QUALITY;
    Descrip.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;

    // font creation
    HRESULT hRet = D3DXCreateFontIndirect( m_pD3DDevice, &Descrip, &m_pFont );
    if(FAILED(hRet)) return false;

    In my WM_SIZE code:

    if(m_pD3DDevice)
    {
    // reset the device
    if(m_pFont) m_pFont->OnLostDevice();
    if(m_pCamera) m_pCamera->SetViewport(m_nViewX, m_nViewY, m_nViewWidth, m_nViewHeight, 1.01f, 5000.0f);
    Initialize.ResetDisplay(m_pD3DDevice, m_D3DSettings);
    if(m_pFont) m_pFont->OnResetDevice();
    SetupRenderStates(); }

    In my Frame Advance function:

    static RECT Rect = { 5, 0, 0, 0};
    m_pFont->DrawText( NULL, FrameRate, -1, &Rect, DT_NOCLIP, D3DXCOLOR( 255, 255, 0, 255 ));

    I have setup this way, to catch on WM_SIZE message to be sure if the user changes the size of window or switches from fullscreen to windowed that the font gets recreated. Hope this helps. Thanks.


    Cale


  • How can I make a console in the game?