当前位置: 首页>>代码示例>>C++>>正文


C++ CFont::Draw方法代码示例

本文整理汇总了C++中CFont::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ CFont::Draw方法的具体用法?C++ CFont::Draw怎么用?C++ CFont::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFont的用法示例。


在下文中一共展示了CFont::Draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char* argv[])
{
	bool show_console = 0;
	bool done = 0;
	int tickCounter = 0;
	int gServer = 0;
	CSocketServer server;
	CSocketClient client;
	CFont font;

	if(argc != 2)
	{
		printf("usage: mecha server|hostname\n");
		return 1;
	}

	gameInit();

	CLog::Get().Init();

	initEngine();

	font.Load("font_big.png");

	if(strcmp(argv[1], "server") == 0)
	{
		gServer = 1;
	}

	clientInit();

	if(gServer)
	{
		if(!server.Listen(4444))
		{
			CLog::Get().Write(APP_LOG, LOG_ERROR, "Listen failed");
			done = 1;
		}
		if(!client.Connect("localhost", 4444))
		{
			CLog::Get().Write(APP_LOG, LOG_ERROR, "Connection failed");
			done = 1;
		}
	}
	else
	{
		if(!client.Connect(argv[1], 4444))
		{
			CLog::Get().Write(APP_LOG, LOG_ERROR, "Connection failed");
			done = 1;
		}
	}

	while(!done)
	{
		timerUpdate();

		tickCounter += timerGetDiff();

		if(show_console)
		{
			if(inpKeyPressed(GLFW_KEY_PAGEUP)) CConsole::ScrollUp();
			if(inpKeyPressed(GLFW_KEY_PAGEDOWN)) CConsole::ScrollDown();
		}
		if(inpKeyPressed(GLFW_KEY_F1))	show_console = !show_console;
		if(inpKeyPressed(GLFW_KEY_ESC)) break;

		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT| GL_STENCIL_BUFFER_BIT);
		glLoadIdentity();

		videoSetPerspective();


		glColor3f(1.0f, 1.0f, 1.0f);

		if(gServer)
			server.Tick();

		client.Tick();

//		if(client.IsConnected())
//			clientTick();

		gfxBlendNormal();

		if(client.IsConnected())
			clientRender(client.GetPreviousSnap(), client.GetCurrentSnap(), client.GetInterpolation());

		gfxSetColor(0.5f, 0.5f, 0.5f, 1.0f);
		videoSetOrtho(800, 600);
		font.Draw(10, 10, "FPS: %f", timerGetFPS());
		font.Draw(10, 25, "Ping: %d", client.m_Ping);
		font.Draw(10, 40, "Snapshot size: %d b", client.GetSnapSize());
		font.Draw(10, 55, "Num objects: %d", client.GetSnapNumObjects());
		videoSetPerspective();

		CConsole::Draw(show_console || !client.IsConnected());

		inpUpdate();

//.........这里部分代码省略.........
开发者ID:dankar,项目名称:zombies,代码行数:101,代码来源:main.cpp

示例2: Update


//.........这里部分代码省略.........
                }
            } // if
        } // for
    } // for
    
    // if debug function enabled: draw some squares showing the accesibility
#if defined(DEBUG_DRAW_SOFTWALL_BLOCKS) || defined(DEBUG_DRAW_BURNWALLDANGER_BLOCKS) || defined(DEBUG_DRAW_BOMB_OWNERS)
    // debug display
    BYTE r, g, b;
    BYTE rbase, gbase, bbase;
    int w, h;

    m_pDisplay->RemoveAllDebugRectangles();
#endif
#ifdef DEBUG_DRAW_SOFTWALL_BLOCKS
    rbase = 128; gbase = 128; bbase = 128; 
    
    w = m_pArena->ToPosition(1);
    h = m_pArena->ToPosition(1);
    
    if (m_pDisplay != NULL)
    {
        m_pDisplay->RemoveAllDebugRectangles();
        for (BlockX = 0 ; BlockX < ARENA_WIDTH ; BlockX++)
        {
            for (BlockY = 0 ; BlockY < ARENA_HEIGHT ; BlockY++)
            {
                if (m_SoftWallNear[BlockX][BlockY] > 0)
                {
                    r = rbase + m_SoftWallNear[BlockX][BlockY] * 8;
                    g = gbase + m_SoftWallNear[BlockX][BlockY] * 8;
                    b = bbase + m_SoftWallNear[BlockX][BlockY] * 8;
                    
		            m_pDisplay->DrawDebugRectangle (
                        m_pArena->ToPosition(BlockX), 
                        m_pArena->ToPosition(BlockY), 
                        w, h, r, g, b, AIARENADEBUG_SPRITELAYER, PRIORITY_UNUSED);
                }
            }
        }
    }
#endif

    //*************
    // DANGER AND BURNING WALL AND BURNING SOON WALL
    //*************
    
    // Scan each block of the danger array and wallburn array
    for (BlockX = 0 ; BlockX < ARENA_WIDTH ; BlockX++)
    {
        for (BlockY = 0 ; BlockY < ARENA_HEIGHT ; BlockY++)
        {
            // Set no danger for the moment
            m_Danger[BlockX][BlockY] = DANGER_NONE;

            m_DangerTimeLeft[BlockX][BlockY] = 999.0f;

            // Set true if there is a burning wall
            m_WallBurn[BlockX][BlockY] = m_pArena->IsBurningWall(BlockX, BlockY);
        }
    }
    
    // create an index array for the bombs
    // each element represents a bomb. its value is the index to the bomb which
    // will ignite this bomb.
    int *BombIndex = new int[m_pArena->MaxBombs()];
开发者ID:Bombermaaan-R,项目名称:bombermaaan-r,代码行数:67,代码来源:CAiArena.cpp


注:本文中的CFont::Draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。