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


C++ Coin::collect方法代码示例

本文整理汇总了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;
}
开发者ID:slackstone,项目名称:tuxjunior,代码行数:33,代码来源:block.cpp

示例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;
}
开发者ID:ACMEware,项目名称:Paper-Hurricane,代码行数:42,代码来源:block.cpp

示例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;
}
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:23,代码来源:block.cpp


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