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


C++ Sector::add_object方法代码示例

本文整理汇总了C++中Sector::add_object方法的典型用法代码示例。如果您正苦于以下问题:C++ Sector::add_object方法的具体用法?C++ Sector::add_object怎么用?C++ Sector::add_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sector的用法示例。


在下文中一共展示了Sector::add_object方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BouncyCoin

void
Brick::try_break(bool playerhit)
{
  if(sprite->get_action() == "empty")
    return;

  sound_manager->play("sounds/brick.wav");
  Sector* sector = Sector::current();
  Player& player = *(sector->player);
  if(coin_counter > 0) {
    sector->add_object(new BouncyCoin(get_pos()));
    coin_counter--;
    player.get_status()->add_coins(1);
    if(coin_counter == 0)
      sprite->set_action("empty");
    start_bounce();
  } else if(breakable) {
    if(playerhit){
      if(player.is_big()){
        start_break();
        return;
      } else {
        start_bounce();
        return;
      }
    }
   break_me();
  }
}
开发者ID:slackstone,项目名称:tuxjunior,代码行数:29,代码来源:block.cpp

示例2: if

void
Brick::try_break(Player* player)
{
  if(sprite->get_action() == "empty")
    return;

  SoundManager::current()->play("sounds/brick.wav");
  Sector* sector = Sector::current();
  Player& player_one = *(sector->player);
  if(coin_counter > 0 ){
    sector->add_object(std::make_shared<BouncyCoin>(get_pos(), true));
    coin_counter--;
    player_one.get_status()->add_coins(1);
    if(coin_counter == 0)
      sprite->set_action("empty");
    start_bounce(player);
  } else if(breakable) {
    if(player){
      if(player->is_big()){
        start_break(player);
        return;
      } else {
        start_bounce(player);
        return;
      }
    }
    break_me();
  }
}
开发者ID:leyyin,项目名称:supertux,代码行数:29,代码来源:brick.cpp

示例3: BrokenBrick

void
Block::break_me()
{
  Sector* sector = Sector::current();
  sector->add_object(
      new BrokenBrick(new Sprite(*sprite), get_pos(), Vector(-100, -400)));
  sector->add_object(
      new BrokenBrick(new Sprite(*sprite), get_pos() + Vector(0, 16),
        Vector(-150, -300)));
  sector->add_object(
      new BrokenBrick(new Sprite(*sprite), get_pos() + Vector(16, 0),
        Vector(100, -400)));
  sector->add_object(
      new BrokenBrick(new Sprite(*sprite), get_pos() + Vector(16, 16),
        Vector(150, -300)));
  remove_me();
}
开发者ID:slackstone,项目名称:tuxjunior,代码行数:17,代码来源:block.cpp

示例4: Vector

void
Block::break_me()
{
  Sector* sector = Sector::current();
  sector->add_object(
    std::make_shared<BrokenBrick>(sprite->clone(), get_pos(), Vector(-100, -400)));
  sector->add_object(
    std::make_shared<BrokenBrick>(sprite->clone(), get_pos() + Vector(0, 16),
                                  Vector(-150, -300)));
  sector->add_object(
    std::make_shared<BrokenBrick>(sprite->clone(), get_pos() + Vector(16, 0),
                                  Vector(100, -400)));
  sector->add_object(
    std::make_shared<BrokenBrick>(sprite->clone(), get_pos() + Vector(16, 16),
                                  Vector(150, -300)));
  remove_me();
}
开发者ID:ACMEware,项目名称:Paper-Hurricane,代码行数:17,代码来源:block.cpp

示例5: BrokenBrick

void
Brick::try_break(bool playerhit)
{
  if(sprite->get_action() == "empty")
    return;

  sound_manager->play("sounds/brick.wav");
  Sector* sector = Sector::current();
  Player& player = *(sector->player);
  if(coin_counter > 0) {
    sector->add_object(new BouncyCoin(get_pos()));
    coin_counter--;
    player.get_status()->add_coins(1);
    if(coin_counter == 0)
      sprite->set_action("empty");
    start_bounce();
  } else if(breakable) {
    if(playerhit && !player.is_big()) {
      start_bounce();
      return;
    }

    sector->add_object(
        new BrokenBrick(new Sprite(*sprite), get_pos(), Vector(-100, -400)));
    sector->add_object(
        new BrokenBrick(new Sprite(*sprite), get_pos() + Vector(0, 16),
          Vector(-150, -300)));
    sector->add_object(
        new BrokenBrick(new Sprite(*sprite), get_pos() + Vector(16, 0),
          Vector(100, -400)));
    sector->add_object(
        new BrokenBrick(new Sprite(*sprite), get_pos() + Vector(16, 16),
          Vector(150, -300)));
    remove_me();
  }
}
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:36,代码来源:block.cpp

示例6: Vector

void
Fireworks::update(float )
{
    if(timer.check()) {
        Sector* sector = Sector::current();
        Vector pos = sector->camera->get_translation();
        pos += Vector(systemRandom.randf(SCREEN_WIDTH),
                      systemRandom.randf(SCREEN_HEIGHT/2));

        float red = systemRandom.randf(1.0);
        float green = systemRandom.randf(1.0);
        //float red = 0.7;
        //float green = 0.9;
        (void) red;
        (void) green;
        sector->add_object(new Particles(pos, 0, 360, Vector(140, 140),
                Vector(0, 0), 45, Color(red, green, 0), 3, 1.3,
                LAYER_FOREGROUND1+1));
        sound_manager->play("sounds/fireworks.wav");
        timer.start(systemRandom.randf(1.0, 1.5));
    }
}
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:22,代码来源:fireworks.cpp

示例7: assert

void
BonusBlock::try_open()
{
  if(sprite->get_action() == "empty") {
    sound_manager->play("sounds/brick.wav");
    return;
  }

  Sector* sector = Sector::current();
  assert(sector);
  assert(sector->player);
  Player& player = *(sector->player);
  Direction direction = (player.get_bbox().get_middle().x > get_bbox().get_middle().x) ? LEFT : RIGHT;

  switch(contents) {
    case CONTENT_COIN:
      Sector::current()->add_object(new BouncyCoin(get_pos()));
      player.get_status()->add_coins(1);
      break;

    case CONTENT_FIREGROW:
      if(player.get_status()->bonus == NO_BONUS) {
        SpecialRiser* riser = new SpecialRiser(get_pos(), new GrowUp(direction));
        sector->add_object(riser);
      } else {
        SpecialRiser* riser = new SpecialRiser(
            get_pos(), new Flower(FIRE_BONUS));
        sector->add_object(riser);
      }
      sound_manager->play("sounds/upgrade.wav");
      break;

    case CONTENT_ICEGROW:
      if(player.get_status()->bonus == NO_BONUS) {
        SpecialRiser* riser = new SpecialRiser(get_pos(), new GrowUp(direction));
        sector->add_object(riser);
      } else {
        SpecialRiser* riser = new SpecialRiser(
            get_pos(), new Flower(ICE_BONUS));
        sector->add_object(riser);
      }
      sound_manager->play("sounds/upgrade.wav");
      break;

    case CONTENT_STAR:
      sector->add_object(new Star(get_pos() + Vector(0, -32), direction));
      break;

    case CONTENT_1UP:
      sector->add_object(new OneUp(get_pos(), direction));
      break;

    case CONTENT_CUSTOM:
      SpecialRiser* riser = new SpecialRiser(get_pos(), object);
      object = 0;
      sector->add_object(riser);
      sound_manager->play("sounds/upgrade.wav");
      break;
  }

  start_bounce();
  sprite->set_action("empty");
}
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:63,代码来源:block.cpp

示例8: stream

void
BonusBlock::try_drop(Player *player)
{
  if(sprite->get_action() == "empty") {
    SoundManager::current()->play("sounds/brick.wav");
    return;
  }

  Sector* sector = Sector::current();
  assert(sector);

  // First what's below the bonus block, if solid send it up anyway (excepting doll)
  Rectf dest_;
  dest_.p1.x = bbox.get_left() + 1;
  dest_.p1.y = bbox.get_bottom() + 1;
  dest_.p2.x = bbox.get_right() - 1;
  dest_.p2.y = dest_.p1.y + 30;
  if (!Sector::current()->is_free_of_statics(dest_, this, true) && !(contents == CONTENT_1UP)) {
    try_open(player);
    return;
  }

  if (player == NULL)
    player = sector->player;

  if (player == NULL)
    return;

  Direction direction = (player->get_bbox().get_middle().x > bbox.get_middle().x) ? LEFT : RIGHT;

  bool countdown = false;

  switch(contents) {
    case CONTENT_COIN:
    {
      try_open(player);
      break;
    }

    case CONTENT_FIREGROW:
    {
      drop_growup_bonus("images/powerups/fireflower/fireflower.sprite", countdown);
      break;
    }

    case CONTENT_ICEGROW:
    {
      drop_growup_bonus("images/powerups/iceflower/iceflower.sprite", countdown);
      break;
    }

    case CONTENT_AIRGROW:
    {
      drop_growup_bonus("images/powerups/airflower/airflower.sprite", countdown);
      break;
    }

    case CONTENT_EARTHGROW:
    {
      drop_growup_bonus("images/powerups/earthflower/earthflower.sprite", countdown);
      break;
    }

    case CONTENT_STAR:
    {
      sector->add_object(std::make_shared<Star>(get_pos() + Vector(0, 32), direction));
      SoundManager::current()->play("sounds/upgrade.wav");
      countdown = true;
      break;
    }

    case CONTENT_1UP:
    {
      sector->add_object(std::make_shared<OneUp>(get_pos(), DOWN));
      SoundManager::current()->play("sounds/upgrade.wav");
      countdown = true;
      break;
    }

    case CONTENT_CUSTOM:
    {
      //NOTE: non-portable trampolines could be moved to CONTENT_CUSTOM, but they should not drop
      object->set_pos(get_pos() +  Vector(0, 32));
      sector->add_object(object);
      object = 0;
      SoundManager::current()->play("sounds/upgrade.wav");
      countdown = true;
      break;
    }

    case CONTENT_SCRIPT:
    {
      countdown = true;
      break;
    } // because scripts always run, this prevents default contents from being assumed

    case CONTENT_LIGHT:
    {
      try_open(player);
      break;
//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:supertux,代码行数:101,代码来源:bonus_block.cpp


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