本文整理汇总了C++中Coin::collect方法的典型用法代码示例。如果您正苦于以下问题:C++ Coin::collect方法的具体用法?C++ Coin::collect怎么用?C++ Coin::collect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coin
的用法示例。
在下文中一共展示了Coin::collect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hit
HitResponse
Block::collision(GameObject& other, const CollisionHit& )
{
Player* player = dynamic_cast<Player*> (&other);
if(player) {
if(player->get_bbox().get_top() > get_bbox().get_bottom() - 7.0) {
hit(*player);
}
}
// only interact with other objects if...
// 1) we are bouncing
// and
// 2) the object is not portable (either never or not currently)
Portable* portable = dynamic_cast<Portable*> (&other);
if(bouncing && (portable == 0 || (!portable->is_portable()))) {
// Badguys get killed
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy) {
badguy->kill_fall();
}
// Coins get collected
Coin* coin = dynamic_cast<Coin*> (&other);
if(coin) {
coin->collect();
}
}
return SOLID;
}
示例2: hit
HitResponse
Block::collision(GameObject& other, const CollisionHit& )
{
Player* player = dynamic_cast<Player*> (&other);
if(player) {
if(player->get_bbox().get_top() > get_bbox().get_bottom() - SHIFT_DELTA) {
hit(*player);
}
}
// only interact with other objects if...
// 1) we are bouncing
// 2) the object is not portable (either never or not currently)
// 3) the object is being hit from below (baguys don't get killed for activating boxes)
Portable* portable = dynamic_cast<Portable*> (&other);
MovingObject* moving_object = dynamic_cast<MovingObject*> (&other);
bool is_portable = ((portable != 0) && portable->is_portable());
bool hit_mo_from_below = ((moving_object == 0) || (moving_object->get_bbox().get_bottom() < (get_bbox().get_top() + SHIFT_DELTA)));
if(bouncing && !is_portable && hit_mo_from_below) {
// Badguys get killed
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy) {
badguy->kill_fall();
}
// Coins get collected
Coin* coin = dynamic_cast<Coin*> (&other);
if(coin) {
coin->collect();
}
//Eggs get jumped
GrowUp* growup = dynamic_cast<GrowUp*> (&other);
if(growup) {
growup->do_jump();
}
}
return FORCE_MOVE;
}
示例3: hit
HitResponse
Block::collision(GameObject& other, const CollisionHit& )
{
Player* player = dynamic_cast<Player*> (&other);
if(player) {
if(player->get_bbox().get_top() > get_bbox().get_bottom() - 7.0) {
hit(*player);
}
}
if(bouncing) {
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy) {
badguy->kill_fall();
}
Coin* coin = dynamic_cast<Coin*> (&other);
if(coin) {
coin->collect();
}
}
return SOLID;
}