/** * \brief The fonction called when there is a new bonus. * \param animation The name of the new bonus. */ void ptb::throwable_item_component::create_floating_bonus ( const std::string& name ) { bear::visual::animation anim = get_level_globals().auto_sprite( "gfx/ui/ui-1.png", name ); bear::visual::position_type rate(0,0); if ( get_player() != NULL ) { rate.x = ( get_player().get_left() - get_player().get_level().get_camera_center().x) / get_player().get_level().get_camera()->get_width(); rate.y = ( get_player().get_bottom() - get_player().get_level().get_camera_center().y) / get_player().get_level().get_camera()->get_height(); } bear::visual::position_type pos(get_layer_size()/2); pos.x += ( rate.x * get_layer_size().x); pos.y += ( rate.y * get_layer_size().y); if ( ( pos.x <= get_layer_size().x ) && ( pos.y <= get_layer_size().y ) && ( pos.x + anim.width() >= 0 ) && ( pos.y + anim.height() >= 0 ) ) { floating_bonus f(name); m_floating_bonus.push_back(f); m_floating_bonus.back().set_position ( pos - anim.get_size()/2, get_render_position() - anim.get_size()/2); } } // throwable_item_component::create_floating_bonus
/** * \brief Create a floating corrupting_bonus. */ void ptb::corrupting_bonus_component::create_floating_corrupting_bonus() { bear::visual::position_type pos(get_layer_size()/2); pos.x += ( game_variables::get_corrupting_bonus_rate_x() * get_layer_size().x); pos.y += ( game_variables::get_corrupting_bonus_rate_y() * get_layer_size().y); if ( ( pos.x <= get_layer_size().x ) && ( pos.y <= get_layer_size().y ) && ( pos.x + m_corrupting_bonus.width() >= 0 ) && ( pos.y + m_corrupting_bonus.height() >= 0 ) ) { floating_corrupting_bonus f; m_floating_corrupting_bonus.push_back(f); m_floating_corrupting_bonus.back().set_position (pos, get_render_position()); } else on_corrupting_bonus_added(); } // corrupting_bonus_component::create_floating_corrupting_bonus()
/** * \brief The fonction called when new_score game variable changes. * \param value The value of the variable new_score. */ void rp::score_component::on_new_score(bool value) { if ( value ) { bear::visual::position_type pos(get_layer_size()/2); pos.x += ( game_variables::get_score_rate_x() * get_layer_size().x); pos.y += ( game_variables::get_score_rate_y() * get_layer_size().y); bear::visual::position_type end_pos(pos); end_pos.y = get_layer_size().y; floating_score_component f(get_level_globals()); m_floating_score.push_back(f); m_floating_score.back().set_position (pos, get_render_position() + bear::universe::position_type( width() / 2, 0 ) ); game_variables::set_new_score(false); } } // score_component::on_new_score()