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


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

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


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

示例1: DrawCursorTile

void DrawCursorTile()
{
    // Create a rect to specify what part of our bitmaps we want to draw
    RECT rPortion = {0, 0, TILE_WIDTH, TILE_HEIGHT};

    // Here we update our cursor position and convert it to client
    // coordinates (our window coordinates), not the screen coordinates.
    GetCursorPos(&g_cursorPos);
    ScreenToClient(g_hWnd, &g_cursorPos);

    // Since exits down have a bitmap associated with them, we need
    // to tell this function it's okay if there isn't a valid cursor tile
    // only if the current type selected is exits.
    if(g_pCurrentMap->GetCurrentType() != EXIT_TYPE)
        if(!g_pCursorTile) return;

    // If the current type is a normal map tile, draw it with no transparency.
    // We line up the cursor bitmap so that it's dead center on the cursor.
    if(g_pCurrentMap->GetCurrentType() == TILE_TYPE)
        g_Buffer.DisplayBitmap(g_pCursorTile->GetBitmap(),
                               g_cursorPos.x - TILE_WIDTH/2, g_cursorPos.y - TILE_HEIGHT/2, rPortion);
    // If we are wanting to insert an exit, just draw a red rectangle
    else if(g_pCurrentMap->GetCurrentType() == EXIT_TYPE)
        Rectangle(g_Buffer.GetHDC(), g_cursorPos.x - TILE_WIDTH/2, g_cursorPos.y - TILE_HEIGHT/2,
                  g_cursorPos.x + TILE_WIDTH/2, g_cursorPos.y + TILE_HEIGHT/2);
    // Otherwise draw a transparent bitmap for the rest of the tile tiles (items, monsters, etc...)
    else
        g_Buffer.DisplayTransparentBitmap(g_pCursorTile->GetBitmap(),
                                          g_cursorPos.x - TILE_WIDTH/2, g_cursorPos.y - TILE_HEIGHT/2, rPortion);

    // If the left button is still help down
    if(g_bLButtonDown)
    {
        // Grab the index on our 2D map depending on our cursor position
        int mapIndexX = g_cursorPos.x / TILE_WIDTH;
        int mapIndexY = g_cursorPos.y / TILE_HEIGHT;

        // Insert the tile type into our map according to it's index
        g_pCurrentMap->InsertTile(g_pCursorTile, mapIndexX, mapIndexY);

        // If it's not a normal tile, don't allow multiple draws per click.
        // If you want to allow rapid drawing of other objects, delete this.
        if(g_pCurrentMap->GetCurrentType() != TILE_TYPE)
            g_bLButtonDown = 0;
    }
}
开发者ID:CHMyFork,项目名称:tutorials,代码行数:46,代码来源: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::DisplayTransparentBitmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。