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


C++ SoccerWorld::getNumKarts方法代码示例

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


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

示例1: drawScores

/** Shows the current soccer result.
 */
void RaceGUI::drawScores()
{
    SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
    int offsetY = 5;
    int offsetX = 5;
    gui::ScalableFont* font = GUIEngine::getFont();
    static video::SColor color = video::SColor(255,255,255,255);

    //Draw kart icons above score(denoting teams)
    irr::video::ITexture *red_team = irr_driver->getTexture(FileManager::GUI,
                                                            "soccer_ball_red.png");
    irr::video::ITexture *blue_team = irr_driver->getTexture(FileManager::GUI,
                                                             "soccer_ball_blue.png");
    irr::video::ITexture *team_icon;

    int numLeader = 1;
    for(unsigned int i=0; i<soccerWorld->getNumKarts(); i++)
    {
        int j = soccerWorld->getTeamLeader(i);
        if(j < 0) break;

        AbstractKart* kart = soccerWorld->getKart(i);
        video::ITexture* icon = kart->getKartProperties()->getMinimapIcon();
        core::rect<s32> source(core::position2di(0, 0), icon->getSize());
        core::recti position(offsetX, offsetY,
            offsetX + 2*m_minimap_player_size, offsetY + 2*m_minimap_player_size);
        draw2DImage(icon, position, source,
            NULL, NULL, true);
        core::stringw score = StringUtils::toWString(soccerWorld->getScore(i));
        int string_height =
            GUIEngine::getFont()->getDimension(score.c_str()).Height;
        core::recti pos(position.UpperLeftCorner.X + 5,
                        position.LowerRightCorner.Y + offsetY,
                        position.LowerRightCorner.X,
                        position.LowerRightCorner.Y + string_height);

        font->draw(score.c_str(),pos,color);
        
        switch(numLeader)
        {
            case 1: team_icon = red_team; break;
            case 2: team_icon = blue_team; break;
            default: break;
        }
        core::rect<s32> indicatorPos(offsetX, offsetY,
                                     offsetX + (int)(m_minimap_player_size/1.25f),
                                     offsetY + (int)(m_minimap_player_size/1.25f));
        core::rect<s32> sourceRect(core::position2d<s32>(0,0),
                                                   team_icon->getOriginalSize());
        draw2DImage(team_icon,indicatorPos,sourceRect,
            NULL,NULL,true);
        numLeader++;
        offsetX += position.LowerRightCorner.X;
    }
}   // drawScores
开发者ID:parasgandhi,项目名称:stk-code,代码行数:57,代码来源:race_gui.cpp


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