本文整理汇总了C++中SoccerWorld::getScore方法的典型用法代码示例。如果您正苦于以下问题:C++ SoccerWorld::getScore方法的具体用法?C++ SoccerWorld::getScore怎么用?C++ SoccerWorld::getScore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoccerWorld
的用法示例。
在下文中一共展示了SoccerWorld::getScore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例2: drawScores
/** Shows the current soccer result.
*/
void RaceGUI::drawScores()
{
#ifndef SERVER_ONLY
SoccerWorld* sw = dynamic_cast<SoccerWorld*>(World::getWorld());
int offset_y = 5;
int offset_x = 5;
gui::ScalableFont* font = GUIEngine::getTitleFont();
static video::SColor color = video::SColor(255,255,255,255);
//Draw two teams score
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 = red_team;
for(unsigned int i=0; i<2; i++)
{
core::recti position(offset_x, offset_y,
offset_x + 2*m_minimap_player_size, offset_y + 2*m_minimap_player_size);
core::stringw score = StringUtils::toWString(sw->getScore((SoccerTeam)i));
int string_height =
GUIEngine::getFont()->getDimension(score.c_str()).Height;
core::recti pos(position.UpperLeftCorner.X + 5,
position.LowerRightCorner.Y + offset_y,
position.LowerRightCorner.X,
position.LowerRightCorner.Y + string_height);
font->draw(score.c_str(),pos,color);
if (i == 1)
{
team_icon = blue_team;
}
core::rect<s32> indicator_pos(offset_x, offset_y,
offset_x + (int)(m_minimap_player_size*2),
offset_y + (int)(m_minimap_player_size*2));
core::rect<s32> source_rect(core::position2d<s32>(0,0),
team_icon->getSize());
draw2DImage(team_icon,indicator_pos,source_rect,
NULL,NULL,true);
offset_x += position.LowerRightCorner.X + 30;
}
#endif
} // drawScores
示例3: displaySoccerResults
//-----------------------------------------------------------------------------
void RaceResultGUI::displaySoccerResults()
{
//Draw win text
core::stringw resultText;
static video::SColor color = video::SColor(255, 255, 255, 255);
gui::IGUIFont* font = GUIEngine::getTitleFont();
int currX = UserConfigParams::m_width/2;
RowInfo *ri = &(m_all_row_infos[0]);
int currY = (int)ri->m_y_pos;
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
int teamScore[2] = {soccerWorld->getScore(0), soccerWorld->getScore(1)};
GUIEngine::Widget *table_area = getWidget("result-table");
int height = table_area->m_h + table_area->m_y;
if(teamScore[0] > teamScore[1])
{
resultText = _("Red Team Wins");
}
else if(teamScore[1] > teamScore[0])
{
resultText = _("Blue Team Wins");
}
else
{
//Cannot really happen now. Only in time limited matches.
resultText = _("It's a draw");
}
core::rect<s32> pos(currX, currY, currX, currY);
font->draw(resultText.c_str(), pos, color, true, true);
core::dimension2du rect = m_font->getDimension(resultText.c_str());
//Draw team scores:
currY += rect.Height;
currX /= 2;
irr::video::ITexture* redTeamIcon = irr_driver->getTexture(FileManager::GUI,
"soccer_ball_red.png");
irr::video::ITexture* blueTeamIcon = irr_driver->getTexture(FileManager::GUI,
"soccer_ball_blue.png");
core::recti sourceRect(core::vector2di(0,0), redTeamIcon->getSize());
core::recti destRect(currX, currY, currX+redTeamIcon->getSize().Width/2,
currY+redTeamIcon->getSize().Height/2);
draw2DImage(redTeamIcon, destRect,sourceRect,
NULL,NULL, true);
currX += UserConfigParams::m_width/2 - redTeamIcon->getSize().Width/2;
destRect = core::recti(currX, currY, currX+redTeamIcon->getSize().Width/2,
currY+redTeamIcon->getSize().Height/2);
draw2DImage(blueTeamIcon,destRect,sourceRect,
NULL, NULL, true);
resultText = StringUtils::toWString(teamScore[1]);
rect = m_font->getDimension(resultText.c_str());
currX += redTeamIcon->getSize().Width/4;
currY += redTeamIcon->getSize().Height/2 + rect.Height/4;
pos = core::rect<s32>(currX, currY, currX, currY);
color = video::SColor(255,255,255,255);
font->draw(resultText.c_str(), pos, color, true, false);
currX -= UserConfigParams::m_width/2 - redTeamIcon->getSize().Width/2;
resultText = StringUtils::toWString(teamScore[0]);
pos = core::rect<s32>(currX,currY,currX,currY);
font->draw(resultText.c_str(), pos, color, true, false);
int centerX = UserConfigParams::m_width/2;
pos = core::rect<s32>(centerX, currY, centerX, currY);
font->draw("-", pos, color, true, false);
//Draw goal scorers:
//The red scorers:
currY += rect.Height/2 + rect.Height/4;
font = GUIEngine::getSmallFont();
std::vector<int> scorers = soccerWorld->getScorers(0);
std::vector<float> scoreTimes = soccerWorld->getScoreTimes(0);
irr::video::ITexture* scorerIcon;
int prevY = currY;
for(unsigned int i=0; i<scorers.size(); i++)
{
resultText = soccerWorld->getKart(scorers.at(i))->
getKartProperties()->getName();
resultText.append(" ");
resultText.append(StringUtils::timeToString(scoreTimes.at(i)).c_str());
rect = m_font->getDimension(resultText.c_str());
if(height-prevY < ((short)scorers.size()+1)*(short)rect.Height)
currY += (height-prevY)/((short)scorers.size()+1);
else
currY += rect.Height;
if(currY > height) break;
pos = core::rect<s32>(currX,currY,currX,currY);
font->draw(resultText,pos, color, true, false);
scorerIcon = soccerWorld->getKart(scorers.at(i))
->getKartProperties()->getIconMaterial()->getTexture();
sourceRect = core::recti(core::vector2di(0,0), scorerIcon->getSize());
//.........这里部分代码省略.........