コード例 #1
0
/**
 * \brief Constructor.
 * \param glob Level globals in which we take the resources.
 * \param p The player from which we take the data.
 * \param active_position the position in active state.
 * \param side Indicates the side on which the component appears.
 * \param x_p The placement on x-coordinate.
 * \param y_p The placement on y-coordinate.
 * \param layer_size The size of the layer in which the component is displayed.
 */
ptb::score_component::score_component
( bear::engine::level_globals& glob, const player_proxy& p,
  const bear::visual::position_type& active_position, 
  bear::universe::zone::position side,
  x_placement x_p, y_placement y_p,
  const bear::universe::size_box_type& layer_size )
  : super(glob,p,active_position,side, x_p, y_p, layer_size),
    m_font(glob.get_font("font/bouncy.fnt", 30))
{

} // score_component::score_component()
コード例 #2
0
ファイル: score_component.cpp プロジェクト: fcjailybo/asgp
/**
 * \brief Constructor.
 * \param glob Level globals in which we take the resources.
 * \param active_position the position in active state.
 * \param side Indicates the side on which the component appears.
 * \param x_p The placement on x-coordinate.
 * \param y_p The placement on y-coordinate.
 * \param layer_size The size of the layer in which the component is displayed.
 * \param flip Indicates if picture must be flipped.
 */
rp::score_component::score_component
( bear::engine::level_globals& glob,
  const bear::visual::position_type& active_position,
  bear::universe::zone::position side,
  x_placement x_p, y_placement y_p,
  const bear::universe::size_box_type& layer_size,
  const bear::universe::coordinate_type& hide_height, bool flip )
  : super(glob,active_position,side, x_p, y_p, layer_size, hide_height, flip),
    m_font(glob.get_font("font/beroga.ttf", 20))
{

} // score_component::score_component()
コード例 #3
0
/**
 * \brief Constructor.
 * \param glob Level globals in which we take the resources.
 * \param p The player from which we take the data.
 * \param active_position the position in active state.
 * \param side Indicates the side on which the component appears.
 * \param x_p The placement on x-coordinate.
 * \param y_p The placement on y-coordinate.
 * \param layer_size The size of the layer in which the component is displayed.
 * \param auto_disappear Indicates that the component disappears automatically.
 */
ptb::throwable_item_component::throwable_item_component
( bear::engine::level_globals& glob, const player_proxy& p,
  const bear::visual::position_type& active_position, 
  bear::universe::zone::position side,
  x_placement x_p, y_placement y_p,
  const bear::universe::size_box_type& layer_size,
  bool auto_disappear )
  : super(glob,p,active_position,side, x_p, y_p, layer_size, auto_disappear),
    m_font(glob.get_font("font/Fava-black.ttf", 30))
{

} // throwable_item_component::throwable_item_component()
コード例 #4
0
/**
 * \brief Adjust the distance between the player and the arrow.
 * \param glob The level globals in which we load the media.
 * \param visible_area The visible part of the layer.
 */
void ptb::player_arrows_layer::player_data::adjust_distance
( bear::engine::level_globals& glob,
  const bear::universe::rectangle_type& visible_area )
{
  claw::math::coordinate_2d<double> ratio
    ( visible_area.size().x / m_screen_size.x,
      visible_area.size().y / m_screen_size.y );

  bear::universe::position_type relative_position;
  relative_position.x = visible_area.left() +
    ( m_position.x + m_arrow.width() / 2 ) * ratio.x;

  relative_position.y = visible_area.bottom() +
    ( m_screen_size.y - m_position.y - m_arrow.height() / 2 ) * ratio.y;

  bear::universe::speed_type vect
    (m_player.get_center_of_mass(), relative_position);
  unsigned int dist = (unsigned int)vect.length() / 100;

  const bear::universe::rectangle_type box = m_player.get_bounding_box();
  bear::visual::font f = glob.get_font("font/Fava-black.ttf", 30);
  if ( box.intersects( visible_area ) )
    m_distance.create(f, "");
  else
    {
      std::ostringstream oss;
      oss << dist+1;
      m_distance.create(f, oss.str());
      m_distance->set_intensity(1, 0.8, 0);
    }

  m_distance_text_position = m_position;

  bear::universe::position_type gap;
  gap.x = cos(m_arrow.get_angle()) * 50;
  gap.y = sin(m_arrow.get_angle()) * 50;

  m_distance_text_position.x +=
    m_arrow.width() / 2 - gap.x - m_distance.get_width() / 2;
  m_distance_text_position.y +=
    m_arrow.height() / 2 - gap.y - m_distance.get_height() / 2;
} // player_arrows_layer::player_data::adjust_distance()