本文整理汇总了C++中Kart::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Kart::getName方法的具体用法?C++ Kart::getName怎么用?C++ Kart::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kart
的用法示例。
在下文中一共展示了Kart::getName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newLap
/** Is called by check structures if a kart starts a new lap.
* \param kart_index Index of the kart.
*/
void LinearWorld::newLap(unsigned int kart_index)
{
KartInfo &kart_info = m_kart_info[kart_index];
Kart *kart = m_karts[kart_index];
// Don't do anything if a kart that has already finished the race
// crosses the start line again. This avoids 'fastest lap' messages
// if the end controller does a fastest lap.
if(kart->hasFinishedRace()) return;
const int lap_count = race_manager->getNumLaps();
// Only increase the lap counter and set the new time if the
// kart hasn't already finished the race (otherwise the race_gui
// will begin another countdown).
if(kart_info.m_race_lap+1 <= lap_count)
{
assert(kart->getWorldKartId()==kart_index);
setTimeAtLapForKart(getTime(), kart_index );
kart_info.m_race_lap++ ;
}
// Last lap message (kart_index's assert in previous block already)
if(kart_info.m_race_lap+1 == lap_count)
{
m_race_gui->addMessage(_("Final lap!"), m_karts[kart_index],
3.0f, 40, video::SColor(255, 210, 100, 50), true);
if(!m_last_lap_sfx_played && lap_count > 1)
{
m_last_lap_sfx->play();
m_last_lap_sfx_played = true;
m_last_lap_sfx_playing = true;
// In case that no music is defined
if(music_manager->getCurrentMusic() && music_manager->getMasterMusicVolume() > 0.2f)
{
music_manager->getCurrentMusic()->setTemporaryVolume(0.2f);
}
}
}
// The race positions must be updated here: consider the situation where
// the first kart does not cross the finish line in its last lap, instead
// it passes it, the kart reverses and crosses the finishing line
// backwards. Just before crossing the finishing line the kart will be on
// the last lap, but with a distance along the track close to zero.
// Therefore its position will be wrong. If the race position gets updated
// after increasing the number of laps (but before tagging the kart to have
// finished the race) the position will be correct (since the kart now
// has one additional lap it will be ahead of the other karts).
// Without this call the incorrect position for this kart would remain
// (since a kart that has finished the race does not get its position
// changed anymore), potentially resulting in a duplicated race position
// (since the first kart does not have position 1, no other kart can get
// position 1, so one rank will be duplicated).
// Similarly the situation can happen if the distance along track should
// go back to zero before actually crossing the finishing line. While this
// should not happen, it could potentially be caused by floating point
// errors. In this case the call to updateRacePosition will avoid
// duplicated race positions as well.
updateRacePosition();
// Race finished
if(kart_info.m_race_lap >= race_manager->getNumLaps() && raceHasLaps())
{
// A client wait does not detect race finished by itself, it will
// receive a message from the server. So a client does not do
// anything here.
if(network_manager->getMode()!=NetworkManager::NW_CLIENT)
{
kart->finishedRace(getTime());
}
}
{
float time_per_lap;
if (kart_info.m_race_lap == 1) // just completed first lap
{
time_per_lap=getTime();
}
else //completing subsequent laps
{
time_per_lap=getTime() - kart_info.m_lap_start_time;
}
// if new fastest lap
if(time_per_lap < getFastestLapTime() && raceHasLaps() &&
kart_info.m_race_lap>0)
{
setFastestLap(kart, time_per_lap);
m_race_gui->addMessage(_("New fastest lap"), NULL,
2.0f, 40, video::SColor(255, 100, 210, 100), true);
std::string s = StringUtils::timeToString(time_per_lap);
irr::core::stringw m_fastest_lap_message;
//I18N: as in "fastest lap: 60 seconds by Wilber"
m_fastest_lap_message += StringUtils::insertValues(_("%s by %s"), s.c_str(), kart->getName().c_str()).c_str();
m_race_gui->addMessage(m_fastest_lap_message, NULL,
//.........这里部分代码省略.........