예제 #1
0
파일: bridge.cpp 프로젝트: yannicklm/bear
/**
 * \brief Align \a that on the bridge.
 * \param that The other item of the collision.
 * \param info Some informations about the collision.
 */
bool bear::bridge::align_on_bridge
( engine::base_item& that, universe::collision_info& info )
{
  bool result = false;
  
  universe::position_type previous_pos;
  universe::position_type next_pos;
  
  compute_neighboor
    (info.other_previous_state().get_bottom_middle(),previous_pos,next_pos);
  if ( check_item
       ( info.other_previous_state().get_bottom_middle(),
	 previous_pos, next_pos, 0 ) )
    {
      compute_neighboor(that.get_bottom_middle(),previous_pos,next_pos);

      if ( ! check_item( that.get_bottom_middle(), previous_pos, next_pos, 
			 s_line_width ) ) 
	{
	  universe::position_type pos = 
	    compute_align_position(that,previous_pos, next_pos);

	  apply_angle_to(that,info);
	  
	  return collision_align_top(info, pos);	  
	}
    }
  return result;
} // bridge::align_on_bridge()
예제 #2
0
/**
 * \brief Align the other item of the collision.
 * \param info Some informations about the collision.
 * \param policy The description of how to align the items.
 */
bool bear::universe::physical_item::default_collision
( const collision_info& info, const collision_align_policy& policy )
{
  bool result(false);
  position_type p( info.get_bottom_left_on_contact() );

  switch( info.get_collision_side() )
    {
    case zone::bottom_zone:
      p.y -= get_align_epsilon();
      result = collision_align_bottom(info, p, policy);
      break;
    case zone::top_zone:
      p.y += get_align_epsilon();
      result = collision_align_top(info, p, policy);
      break;
    case zone::middle_left_zone:
      p.x -= get_align_epsilon();
      result = collision_align_left(info, p, policy);
      break;
    case zone::middle_right_zone:
      p.x += get_align_epsilon();
      result = collision_align_right(info, p, policy);
      break;
    case zone::middle_zone:
      result = collision_middle(info, policy);
      break;
    default: { CLAW_ASSERT( false, "Invalid collision side." ); }
    }

  return result;
} // physical_item::default_collision()
예제 #3
0
/**
 * \brief Align the other item of the collision on the top of \a this.
 * \param info Some informations about the collision.
 * \param policy The description of how to align the items.
 */
bool bear::universe::physical_item::collision_align_top
( const collision_info& info, const collision_align_policy& policy )
{
  position_type pos;

  if ( info.get_collision_side() == zone::top_zone )
    pos = info.get_bottom_left_on_contact();
  else
    pos.set( info.other_item().get_left(), get_top() );

  pos.y += get_align_epsilon();

  return collision_align_top( info, pos, policy );
} // physical_item::collision_align_top()
예제 #4
0
/**
 * \brief Align the other item of the collision on the top of \a this.
 * \param info Some informations about the collision.
 * \param pos The bottom left position to put the other item at.
 */
bool bear::universe::physical_item::collision_align_top
( const collision_info& info, const position_type& pos )
{
  return collision_align_top( info, pos, collision_align_policy() );
} // physical_item::collision_align_top()