Esempio n. 1
0
/**
 * \brief Create level bonus objects.
 */
void ptb::honeypot::create_level_bonus(const std::string& name)
{
  bonus_points* new_bonus = new bonus_points( name, 0 );

  new_bonus->set_picture_filename("gfx/ui/bonus-icons/bonus-icons.png");
  new_bonus->set_picture_name(name);
  new_bonus->set_condition
    ( bear::engine::bool_level_variable_getter(&get_level(), name) );

  new_item( *new_bonus );
  CLAW_ASSERT(new_bonus->is_valid(),
              "The bonus isn't correctly initialized" );
  new_bonus->set_center_of_mass(get_center_of_mass());

  if ( m_id == 1 )
    {
      bonus_points* bonus = new bonus_points( "Honey pots", 5000 );

      bonus->set_points
        ( 5000
          * bear::engine::linear_level_variable_getter<unsigned int>
          (&get_level(), "honeypots_found") );

      new_item( *bonus );
      CLAW_ASSERT(new_bonus->is_valid(),
                  "The bonus isn't correctly initialized" );
      bonus->set_center_of_mass(get_center_of_mass());
    }
} // honeypot::create_level_bonus()
Esempio n. 2
0
/**
 * \brief Create the item representing a new power.
 * \param fill_color The color inside the effect.
 * \param border_color The color of the border of the effect.
 */
void ptb::power_effect::show_change_effect
( const bear::visual::color& fill_color,
  const bear::visual::color& border_color )
{
  bear::star* new_decoration =
    new bear::star( 16, 1, border_color, 2, fill_color );

  new_decoration->set_z_position(get_z_position() - 10);
  new_decoration->set_size( 160, 160 );
  new_item( *new_decoration );
  new_decoration->set_center_of_mass(get_center_of_mass());

  const bear::universe::time_type d(0.5);
  bear::universe::forced_tracking mvt(d);
  mvt.set_reference_point_on_center( *this );
  new_decoration->set_forced_movement(mvt);

  bear::decorative_effect* decoration_effect = new bear::decorative_effect;

  decoration_effect->set_duration(d);
  bear::visual::color init_color, end_color;
  init_color.set(1,1,1,1);
  end_color.set(1,1,1,0);
  decoration_effect->set_color( init_color, end_color );
  decoration_effect->set_item(new_decoration, true);

  new_item( *decoration_effect );
} // power_effect::show_change_effect()
Esempio n. 3
0
/**
 * \brief Function called when the explosition starts.
 */
void rp::zeppelin::explose()
{ 
  set_transportability(false);
  kill_interactive_item();
  drop();
  m_hit = true;
  util::create_floating_score(*this,750);

  bear::universe::position_type pos = get_center_of_mass();
  pos.x -= get_width()/4;

  for ( unsigned int i = 0; i != 3; ++i )
    {
      explosion* item = new explosion(15,20,0.6);
      item->set_z_position(get_z_position() + 1000);
      item->set_combo_value(get_combo_value());
      item->set_center_of_mass(pos);
      new_item( *item );
      CLAW_ASSERT( item->is_valid(),
                   "The explosion of bomb isn't correctly initialized" );
      
      bear::universe::forced_tracking m;
      m.set_reference_point_on_center(*this);
      item->set_forced_movement(m);
      pos.x += get_width()/4;
    }

  start_model_action("explose");
} // zeppelin::explose()
Esempio n. 4
0
/**
 * \brief Do one iteration in the progression of the item.
 * \param elapsed_time Elapsed time since the last call.
 */
void rp::cursor::progress( bear::universe::time_type elapsed_time )
{
  super::progress( elapsed_time );

  m_target_position = get_center_of_mass();

#ifdef __ANDROID__
  const bool visible = 
    ( get_level().get_camera_focus().left()
      + get_level().get_camera_size().x / 4
      < get_horizontal_middle() )
    || ( get_level().get_camera_focus().bottom() + 
         3 * get_level().get_camera_size().y / 4
         > get_vertical_middle() );
#else
  const bool visible =
    ( get_level().get_camera_focus().left()
      + 3 * get_level().get_camera_size().x / 4
      > get_horizontal_middle() )
    || ( get_level().get_camera_focus().bottom()
         + get_level().get_camera_size().y / 4
         < get_vertical_middle() );
#endif

  if ( visible != game_variables::get_status_visibility() )
    game_variables::set_status_visibility(visible);
} // cursor::progress()
Esempio n. 5
0
/**
 * \brief Do one step in the progression of the item.
 * \param elapsed_time Elapsed time since the last call.
 */
void bear::camera_on_object::progress_fit_items
( bear::universe::time_type elapsed_time )
{
  unsigned int nb_objects(0);
  bear::universe::position_type top_left(get_center_of_mass());
  bear::universe::position_type bottom_right(get_center_of_mass());

  handle_list::const_iterator it;
  handle_list remaining_objects;

  for ( it = m_objects.begin(); it != m_objects.end(); ++it )
    if ( (*it).get() != NULL )
      {
        if ( (*it)->get_left() < top_left.x )
          top_left.x = (*it)->get_left();

        if ( (*it)->get_right() > bottom_right.x )
          bottom_right.x = (*it)->get_right();

        if ( (*it)->get_top() > top_left.y )
          top_left.y = (*it)->get_top();

        if ( (*it)->get_bottom() < bottom_right.y )
          bottom_right.y = (*it)->get_bottom();

        ++nb_objects;
        remaining_objects.push_back(*it);
      }

  std::swap(m_objects, remaining_objects);

  if ( nb_objects != 0 )
    {
      universe::position_type center((top_left + bottom_right) /2);
      adjust_position( center , elapsed_time );

      universe::size_type r_init = get_default_size().x / get_default_size().y;
      universe::coordinate_type w(bottom_right.x - top_left.x + 200);
      universe::coordinate_type h(top_left.y  - bottom_right.y + 200*r_init);

      if ( w > h*r_init )
        set_wanted_size(universe::size_box_type(w, w/r_init));
      else
        set_wanted_size(universe::size_box_type(h*r_init, h));
    }
} // camera_on_object::progress_fit_items()
Esempio n. 6
0
/**
 * \brief Create an explosion.
 * \param nb_explosions Number of explosions to display.
 * \param radius The radius of the explosion.
 */
void rp::tnt::create_explosion
(unsigned int nb_explosions, bear::universe::coordinate_type radius)
{ 
  explosion* item = new explosion(nb_explosions,radius, 0.6);
      
  item->set_z_position(get_z_position() + 10);
  item->set_combo_value(get_combo_value());
  item->set_center_of_mass(get_center_of_mass());
  new_item( *item );
  CLAW_ASSERT( item->is_valid(),
               "The explosion of tnt isn't correctly initialized" );
} // tnt::create_explosion()
Esempio n. 7
0
/**
 * \brief Initialize the item.
 */
void rp::switching::on_enters_layer()
{
  super::on_enters_layer();

  set_model_actor( get_level_globals().get_model("model/switching.cm") );
  start_model_action(m_initial_state);
   
  bear::engine::model_mark_placement mark;

  if ( get_mark_placement("sign", mark) )
    create_interactive_item
        (*this, 0.25, 0, mark.get_position() - get_center_of_mass() );
} // rp::switching::on_enters_layer()
Esempio n. 8
0
/**
 * \brief Do post creation actions.
 */
void rp::cursor::on_enters_layer()
{
  super::on_enters_layer();  

  if ( ! m_sprite.is_valid() )
    {
      m_sprite = 
        get_level_globals().auto_sprite( "gfx/status/cursor.png", "default" );
      set_size( m_sprite.get_size() );
    }

  m_target_position = get_center_of_mass();
} // cursor::on_enters_layer()
Esempio n. 9
0
/**
 * \brief Apply the forced movement to the item representing a power for the
 *        case where there are two power.
 * \param item The item for the second power.
 */
void ptb::power_effect::apply_movement_2( bear::engine::base_item& item )
{
  bear::universe::forced_rotation f( create_forced_movement() );

  const double a =
    3.14159
    + get_center_of_mass().slope_angle
    ( get_first_power()->get_center_of_mass() );

  f.set_start_angle(a);
  f.set_end_angle(a + 2 * 3.14159);

  item.set_forced_movement(f);
} // power_effect::apply_movement_2()
/**
 * \brief Create level bonus object.
 */
void ptb::hideout_bonus_item::create_level_bonus()
{
  bonus_points* new_bonus = new bonus_points( "Great explorer", 10000 );

  new_bonus->set_picture_filename("gfx/ui/bonus-icons/bonus-icons.png");
  new_bonus->set_picture_name("hideouts");
  new_bonus->set_condition
   ( bear::engine::bool_level_variable_getter
     (&get_level(), "all_hideouts_found"));

  new_item( *new_bonus );
  CLAW_ASSERT(new_bonus->is_valid(),
              "The bonus isn't correctly initialized" );
  new_bonus->set_center_of_mass(get_center_of_mass());
} // hideout_bonus_item::create_level_bonus()
Esempio n. 11
0
/**
 * \brief Creates the default movement applied to the zeppelin.
 */
void rp::zeppelin::create_default_movement()
{
  bear::reference_item* center = new bear::reference_item;
  center->set_center_of_mass( get_center_of_mass() );
  
  new_item( *center );

  bear::universe::forced_rotation mvt;
  mvt.set_radius( 5 );
  mvt.set_total_time( 5 );
  mvt.set_acceleration_time( 0 );
  mvt.set_reference_point_on_center( *center );

  set_forced_movement( mvt );
} // zeppelin::()
Esempio n. 12
0
/**
 * \brief Create the item representing a given power.
 * \param anim The animation of the power.
 */
bear::engine::base_item*
ptb::power_effect::create_power_item( const std::string& anim ) const
{
  bear::decorative_item* result = new bear::decorative_item();
  bear::visual::animation a = get_level_globals().get_animation(anim);

  a.set_angle(3.14159 / 2);

  result->set_animation(a);
  result->set_system_angle_as_visual_angle(true);
  result->set_mass(1);
  result->set_center_of_mass( get_center_of_mass() );

  new_item(*result);

  return result;
} // power_effect::create_power_item()
Esempio n. 13
0
/**
 * \brief Create a decoration.
 */
void ptb::honeypot::create_decoration()
{
  bear::decorative_item* item = new bear::decorative_item;

  item->set_animation
    (get_level_globals().get_animation
     ("animation/corrupting-bonus-disapearing.canim"));
  item->get_rendering_attributes().set_angle(get_visual_angle());
  item->set_kill_when_finished(true);
  item->set_z_position(get_z_position()-1);

  new_item( *item );

  item->set_center_of_mass(get_center_of_mass());

  CLAW_ASSERT( item->is_valid(),
               "The decoration of corrupting_bonus isn't correctly "
               "initialized" );
} // honeypot::create_decoration()
Esempio n. 14
0
/**
 * \brief Create item.
 */
void rp::zeppelin::create_item()
{
  base_item* const item = m_item->clone();
  
  item->set_top_middle( get_mark_world_position("anchor") );
  item->set_global( is_global() );

  entity* e = dynamic_cast<entity*>( m_item );
  if ( e != NULL )
    item->set_z_position(get_z_position() + 1);
  new_item( *item );

  m_drop_item = handle_type(item);

  bear::universe::forced_tracking mvt
    ( item->get_center_of_mass() - get_center_of_mass() );
  mvt.set_reference_point_on_center( *this );
  mvt.set_auto_remove(true);
  item->set_forced_movement( mvt );
} // zeppelin::create_item()
Esempio n. 15
0
/**
 * \brief Check if a player is visible for the gorilla.
 * \param p The player we are looking for.
 * \param left_orientation True if the orientation is toward the left.
 * \param distance The distance of scan.
 */
bool ptb::gorilla::scan_for_player
( const player_proxy& p, bool left_orientation,
  bear::universe::coordinate_type distance ) const
{
  bool result = false;
  const bool player_on_the_left
    ( p.get_horizontal_middle() <= get_horizontal_middle() );

  if ( !(player_on_the_left ^ left_orientation) )
    {
      bear::engine::model_mark_placement m;
      m.set_position( get_center_of_mass() );
      get_mark_placement("eyes", m);
      bear::universe::position_type pos(p.get_bottom_middle());
      pos.y += 1;

      result = scan_no_wall_in_direction
        ( m.get_position(), pos - m.get_position(), distance );
    }

  return result;
} // gorilla::scan_in_direction()