/** * \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()
/** * \brief Get the sprite representing the item. * \param visuals (out) The sprites of the item, and their positions. */ void rp::cursor::get_visual ( std::list<bear::engine::scene_visual>& visuals ) const { if ( ! get_level().is_paused() && ! game_variables::get_ending_effect() ) { double factor( get_level().get_camera_size().x / 1280 ); bear::visual::position_type pos ( get_horizontal_middle() - m_sprite.width() * factor / 2, get_vertical_middle() - m_sprite.height() * factor / 2); bear::visual::scene_sprite s( pos.x, pos.y, m_sprite); s.set_scale_factor(factor, factor); visuals.push_back( s ); } } // cursor::get_visual
/** * \brief Compute the y coordinate of a given item. * \param item The considered item. */ bear::universe::coordinate_type bear::bridge::compute_giving_way(const base_item& item) const { universe::coordinate_type coord = item.get_mass() * ( ( get_width() / 2 ) - std::abs(item.get_horizontal_middle() - get_horizontal_middle()) ) * m_max_fall / ( get_width() * 50 ); if ( coord > m_max_fall ) coord = m_max_fall; claw::math::line_2d<universe::coordinate_type> line ( m_top_left_ref->get_center_of_mass(), m_top_right_ref->get_center_of_mass() - m_top_left_ref->get_center_of_mass()); return line.y_value( item.get_horizontal_middle() ) - coord; } // bridge::compute_giving_way()
/** * \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()
/** * \brief Call collision_check_and_bounce(). * \param that The other item of the collision. * \param info Some informations about the collision. */ void rp::bonus::collision ( bear::engine::base_item& that, bear::universe::collision_info& info ) { if ( m_bonus_is_given ) return; cart* c = dynamic_cast<cart*>(&that); if ( c != NULL ) if ( c->get_current_action_name() != "dead" && c->get_current_action_name() != "takeoff" ) { m_bonus_is_given = true; give_bonus(c); set_angular_speed(-20); set_mass(1); m_cart = c; m_tweener_y_position.insert ( claw::tween::single_tweener ( 0.0, 300.0, 0.5, boost::bind( &rp::bonus::on_y_position_change, this, _1 ), &claw::tween::easing_quad::ease_out ) ); m_tweener_y_position.insert ( claw::tween::single_tweener ( 300.0, 50.0, 0.5, boost::bind( &rp::bonus::on_y_position_change, this, _1 ), &claw::tween::easing_quad::ease_in ) ); m_tweener_y_position.on_finished (boost::bind( &rp::bonus::kill, this )); m_tweener_x_position.insert ( claw::tween::single_tweener ( get_horizontal_middle() - m_cart->get_horizontal_middle(), 0.0, 1.0, boost::bind( &rp::bonus::on_x_position_change, this, _1 ), &claw::tween::easing_quad::ease_out ) ); } } // bonus::collision()