本文整理汇总了C++中AbstractKart类的典型用法代码示例。如果您正苦于以下问题:C++ AbstractKart类的具体用法?C++ AbstractKart怎么用?C++ AbstractKart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractKart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPlayer
void GamePadDevice::resetAxisDirection(const int axis,
Input::AxisDirection direction)
{
// ignore this while in menus
if (StateManager::get()->getGameState() != GUIEngine::GAME) return;
AbstractKart* pk = getPlayer()->getKart();
if (!pk)
{
Log::error("Binding", "Trying to reset axis for an unknown player.");
return;
}
for(int n=PA_BEFORE_FIRST+1; n<PA_COUNT; n++)
{
const Binding& bind = m_configuration->getBinding(n);
if(bind.getType() == Input::IT_STICKMOTION &&
bind.getId() == axis &&
bind.getDirection()== direction &&
pk->getController() != NULL)
{
((PlayerController*)(pk->getController()))
->action((PlayerAction)n, 0);
return;
}
}
} // resetAxisDirection
示例2: addAttachment
// ----------------------------------------------------------------------------
void addAttachment(Attachment::AttachmentType type)
{
World* world = World::getWorld();
if (world == NULL) return;
for (unsigned int i = 0; i < world->getNumKarts(); i++)
{
AbstractKart *kart = world->getKart(i);
if (!kart->getController()->isLocalPlayerController())
continue;
if (type == Attachment::ATTACH_ANVIL)
{
kart->getAttachment()
->set(type, kart->getKartProperties()->getAnvilDuration());
kart->adjustSpeed(kart->getKartProperties()->getAnvilSpeedFactor());
kart->updateWeight();
}
else if (type == Attachment::ATTACH_PARACHUTE)
{
kart->getAttachment()
->set(type, kart->getKartProperties()->getParachuteDuration());
}
else if (type == Attachment::ATTACH_BOMB)
{
kart->getAttachment()
->set(type, stk_config->m_bomb_time);
}
}
} // addAttachment
示例3: updateReplay
/** Sets the kart position and controls to the recorded history value.
* \param dt Time step size.
*/
void History::updateReplay(float dt)
{
m_current++;
World *world = World::getWorld();
if(m_current>=(int)m_all_deltas.size())
{
Log::info("History", "Replay finished");
m_current = 0;
// Note that for physics replay all physics parameters
// need to be reset, e.g. velocity, ...
world->reset();
}
unsigned int num_karts = world->getNumKarts();
for(unsigned k=0; k<num_karts; k++)
{
AbstractKart *kart = world->getKart(k);
unsigned int index=m_current*num_karts+k;
if(m_replay_mode==HISTORY_POSITION)
{
kart->setXYZ(m_all_xyz[index]);
kart->setRotation(m_all_rotations[index]);
}
else
{
kart->setControls(m_all_controls[index]);
}
}
} // updateReplay
示例4: explode
/** Creates the explosion physical effect, i.e. pushes the karts and ph
* appropriately. The corresponding visual/sfx needs to be added manually!
* \param kart_hit If non-NULL a kart that was directly hit.
* \param object If non-NULL a physical item that was hit directly.
* \param secondary_hits True if items that are not directly hit should
* also be affected.
*/
void Flyable::explode(AbstractKart *kart_hit, PhysicalObject *object,
bool secondary_hits)
{
// Apply explosion effect
// ----------------------
World *world = World::getWorld();
for ( unsigned int i = 0 ; i < world->getNumKarts() ; i++ )
{
AbstractKart *kart = world->getKart(i);
// If no secondary hits should be done, only hit the
// direct hit kart.
if(!secondary_hits && kart!=kart_hit)
continue;
// Handle the actual explosion. The kart that fired a flyable will
// only be affected if it's a direct hit. This allows karts to use
// rockets on short distance.
if( (m_owner!=kart || m_owner==kart_hit) && !kart->getKartAnimation())
{
// The explosion animation will register itself with the kart
// and will free it later.
ExplosionAnimation::create(kart, getXYZ(), kart==kart_hit);
if(kart==kart_hit && world->getTrack()->isArena())
{
world->kartHit(kart->getWorldKartId());
}
}
}
world->getTrack()->handleExplosion(getXYZ(), object, secondary_hits);
} // explode
示例5: chooseTarget
/** Determine the nearest kart or item and update the current target
* accordingly.
*/
void Swatter::chooseTarget()
{
// TODO: for the moment, only handle karts...
const World* world = World::getWorld();
AbstractKart* closest_kart = NULL;
float min_dist2 = FLT_MAX;
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
AbstractKart *kart = world->getKart(i);
// TODO: isSwatterReady(), isSquashable()?
if(kart->isEliminated() || kart==m_kart)
continue;
// don't squash an already hurt kart
if (kart->isInvulnerable() || kart->isSquashed())
continue;
float dist2 = (kart->getXYZ()-m_kart->getXYZ()).length2();
if(dist2<min_dist2)
{
min_dist2 = dist2;
closest_kart = kart;
}
}
m_target = closest_kart; // may be NULL
}
示例6: resetAxisDirection
void GamePadDevice::resetAxisDirection(const int axis,
Input::AxisDirection direction,
StateManager::ActivePlayer* player)
{
// ignore this while in menus
if (StateManager::get()->getGameState() != GUIEngine::GAME) return;
AbstractKart* pk = player->getKart();
if (pk == NULL)
{
fprintf(stderr, "Error, trying to reset axis for an unknown player\n");
return;
}
for(int n=0; n<PA_COUNT; n++)
{
Binding& bind = m_configuration->getBinding(n);
if(bind.getType() == Input::IT_STICKMOTION &&
bind.getId() == axis &&
bind.getDirection()== direction)
{
((PlayerController*)(pk->getController()))
->action((PlayerAction)n, 0);
return;
}
}
} // resetAxisDirection
示例7: target
/** Called when the check line is triggered. This function creates a cannon
* animation object and attaches it to the kart.
* \param kart_index The index of the kart that triggered the check line.
*/
void CheckCannon::trigger(unsigned int kart_index)
{
Vec3 target(m_target.getMiddle());
AbstractKart *kart = World::getWorld()->getKart(kart_index);
if(kart->getKartAnimation()) return;
new CannonAnimation(kart, m_curve->clone());
} // CheckCannon
示例8: setVelocity
/** Sets the kart's velocity to the specified value. */
void setVelocity(int idKart, SimpleVec3* position)
{
float x = position->getX();
float y = position->getY();
float z = position->getZ();
AbstractKart* kart = World::getWorld()->getKart(idKart);
kart->setVelocity(btVector3(x, y, z));
}
示例9: teleport
/** Teleports the kart to the specified Vec3 location */
void teleport(int idKart, SimpleVec3* position)
{
AbstractKart* kart = World::getWorld()->getKart(idKart);
Vec3 v(position->getX(), position->getY(), position->getZ());
kart->setXYZ(v);
unsigned int index = World::getWorld()->getRescuePositionIndex(kart);
btTransform s = World::getWorld()->getRescueTransform(index);
s.setRotation(btQuaternion(btVector3(0.0f, 1.0f, 0.0f), 0.0f));
World::getWorld()->moveKartTo(kart, s);
}
示例10: addPowerup
/** Add powerup selected from debug menu for all player karts */
void addPowerup(PowerupManager::PowerupType powerup)
{
World* world = World::getWorld();
if (!world) return;
for(unsigned int i = 0; i < race_manager->getNumLocalPlayers(); i++)
{
AbstractKart* kart = world->getLocalPlayerKart(i);
kart->setPowerup(powerup, 10000);
}
} // addPowerup
示例11: 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
示例12: setDebugMode
void IrrDebugDrawer::setDebugMode(DebugModeType mode)
{
m_debug_mode = mode;
World *world = World::getWorld();
unsigned int num_karts = world->getNumKarts();
for(unsigned int i=0; i<num_karts; i++)
{
AbstractKart *kart = world->getKart(i);
if(kart->isEliminated()) continue;
kart->getNode()->setVisible(!(m_debug_mode & DM_NO_KARTS_GRAPHICS));
}
} // nextDebugMode
示例13: nextDebugMode
/** Activates the next debug mode, or switches the mode off again.
*/
void IrrDebugDrawer::nextDebugMode()
{
// Go to next debug mode. Note that debug mode 3 (
m_debug_mode = (DebugModeType) ((m_debug_mode+1) % 3);
World *world = World::getWorld();
unsigned int num_karts = world->getNumKarts();
for(unsigned int i=0; i<num_karts; i++)
{
AbstractKart *kart = world->getKart(i);
if(kart->isEliminated()) continue;
kart->getNode()->setVisible(!(m_debug_mode & DM_NO_KARTS_GRAPHICS));
}
} // nextDebugMode
示例14: Message
/** De-serialises a race result message and sets the appropriate results in
* the kart and the race manager.
* \param pkt The enet message paket.
*/
RaceResultMessage::RaceResultMessage(ENetPacket* pkt)
: Message(pkt, MT_RACE_RESULT)
{
World *world = World::getWorld();
const unsigned int num_karts = world->getNumKarts();
for(unsigned int i=0; i<num_karts; i++)
{
AbstractKart *kart = world->getKart(i);
float time = getFloat();
char position = getChar();
kart->setPosition(position);
kart->finishedRace(time);
}
} // RaceResultMessage
示例15: getKart
void OverWorld::onFirePressed(Controller* who)
{
const std::vector<OverworldChallenge>& challenges =
Track::getCurrentTrack()->getChallengeList();
AbstractKart* k = getKart(0);
Vec3 kart_xyz = k->getXYZ();
if (dynamic_cast<RescueAnimation*>(k->getKartAnimation()) != NULL)
{
// you can't start a race while being rescued
return;
}
for (unsigned int n=0; n<challenges.size(); n++)
{
if ( (kart_xyz - Vec3(challenges[n].m_position)).length2_2d()
< CHALLENGE_DISTANCE_SQUARED)
{
if (challenges[n].m_challenge_id == "tutorial")
{
scheduleTutorial();
return;
}
else
{
const ChallengeData* challenge = unlock_manager->getChallengeData(challenges[n].m_challenge_id);
if (challenge == NULL)
{
Log::error("track", "Cannot find challenge named '%s'\n",
challenges[n].m_challenge_id.c_str());
continue;
}
const unsigned int val = challenge->getNumTrophies();
bool unlocked = (PlayerManager::getCurrentPlayer()->getPoints() >= val);
if (UserConfigParams::m_everything_unlocked)
unlocked = true;
if (unlocked)
{
race_manager->setKartLastPositionOnOverworld(kart_xyz);
new SelectChallengeDialog(0.8f, 0.8f,
challenges[n].m_challenge_id);
}
}
} // end if
} // end for
} // onFirePressed