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


C++ CBuffer::SwapBackBuffer方法代码示例

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


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

示例1: MainLoop

WPARAM MainLoop()
{
	MSG msg;
	// This is where we load our accelerators for keyboard shortcuts
	HACCEL hAccelTable = LoadAccelerators(g_hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));

	while(g_Player.IsAlive())							// Loop until the player is dead
	{													// Check if there was a message
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 
        { 
			if(msg.message == WM_QUIT)					// If the message was to quit
				break;

			// Check if there was keyboard command - if not, process messages like normal
			if(!TranslateAccelerator(g_hWnd, hAccelTable, &msg))
			{
				TranslateMessage(&msg);					// Find out what the message does
				DispatchMessage(&msg);					// Execute the message
			}

			// Here is where we handle the main game input
			HandleGameInput();

			// Let's draw the map when we need to draw (if the draw flag == true).
			g_Map.Draw();

			// Just like the g_Map.Draw() command, we will attempt to draw the menu, but it
			// will only be draw if it's draw flag is set to true.  This is the main menu.
			g_Menu.Draw();

			// Swap the backbuffers to display the bitmaps to the screen
			g_Buffer.SwapBackBuffer(FALSE);
		} 

		// We want the Npcs to freely walk around so we need to move them every frame
		g_Map.MoveNpcs();

		// Move the monsters randomly around the map  
		g_Map.MoveMonsters();
	}

	// If the player died because they were killed, let's display a death sound
	if(!g_Player.IsAlive())
	{
		// We use PlaySound() to play our .wav files
		PlaySound("Death.wav", NULL, SND_FILENAME | SND_ASYNC);
		g_Menu.DrawMessageBox("You have perished!");
		Sleep(1000);
	}

	// Clean up and free all allocated memory
	DeInit();											

	// Return from the program
	return(msg.wParam);									
}
开发者ID:Allenjonesing,项目名称:tutorials,代码行数:56,代码来源:Main.cpp

示例2: RenderScene

void RenderScene()
{
    // Make sure we have a current map pointer before we go shootin' blanks
    if(!g_pCurrentMap) return;

    // Here we set the portion of our bitmaps that we want to draw.
    RECT rPortion = {0, 0, TILE_WIDTH, TILE_HEIGHT};

    // Next we draw the current map (Default is just all green grass tiles)
    g_pCurrentMap->Draw();

    // Grab the size of the current tool bar type list (Not our map's placed tile lists)
    int size = g_pCurrentMap->GetCurrentTypeSize();

    // Go through our tiles in the tool bar and draw them, but subtract the scroll bar position
    // from the size.  This makes it so we only draw the tiles that can be seen in the tool bar.
    for(int i = 0; i < size - g_scrollBarPosY; i++)
    {
        // Depending on "i" and the scroll bar position, get the current tile's bitmap to draw
        HBITMAP bitmap = g_pCurrentMap->GetCurrentTypeTile(i + g_scrollBarPosY)->GetBitmap();

        // If the tool bar is showing map tiles then draw the tiles with no transparency
        if(g_pCurrentMap->GetCurrentType() == TILE_TYPE)
            g_ToolBuffer.DisplayBitmap(bitmap, 0, TILE_WIDTH * i, rPortion);
        else
            // Draw the current tiles with a transparency (white) (i.e. items, monsters, etc...)
            g_ToolBuffer.DisplayTransparentBitmap(bitmap, 0, TILE_WIDTH * i, rPortion);
    }


//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////
    DrawCursorTile();					// Draw the current cursor tile if chosen
//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////


    // Swap the backbuffers to display the bitmaps to the screen
    g_Buffer.SwapBackBuffer(FALSE);
    g_ToolBuffer.SwapBackBuffer(TRUE);
}
开发者ID:CHMyFork,项目名称:tutorials,代码行数:39,代码来源:Main.cpp


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