void ViewObject::draw(){ GraphicsManager &graphics_manager = GraphicsManager::getInstance(); string temp_str; if(getBorder() == true){ temp_str = " " + getViewString() + " " + intToString(value) + " "; } else { temp_str = getViewString() + " " + intToString(value); } //Draw centered at position Position pos = viewToWorld(getPosition()); graphics_manager.drawString(pos, temp_str, CENTER_JUSTIFIED, getColor()); //Draw box around display if (getBorder() == true){ int boxLength = strlen(getViewString().c_str()) + 4; int boxHeight = 3; int boxOffset = boxLength/2; bool odd = false; if (boxLength % 2){ odd = true; } for (int i = 0; i < boxLength; i++){ Position new_pos(pos.getX() + i - boxOffset, pos.getY()-1); graphics_manager.drawCh(new_pos, '-', getColor()); } //Bottom for (int i = 0; i < boxLength; i++){ Position new_pos(pos.getX() + i - boxOffset, pos.getY()+1); graphics_manager.drawCh(new_pos, '-', getColor()); } //Left Position left_pos(pos.getX()-boxOffset-1, pos.getY()); graphics_manager.drawCh(left_pos, '|', getColor()); //Right if (!odd){ Position right_pos(pos.getX()+boxOffset, pos.getY()); graphics_manager.drawCh(right_pos, '|', getColor()); } else { Position right_pos(pos.getX()+boxOffset+1, pos.getY()); graphics_manager.drawCh(right_pos, '|', getColor()); } } }
/** * \brief Apply the angle of the slope to a colliding item. * \param that The other item in the collision. * \param info Informations on the collision. */ void bear::bridge::apply_angle_to ( engine::base_item& that, const universe::collision_info& info) const { universe::position_type left_pos(that.get_bottom_left()); universe::position_type right_pos(that.get_bottom_right()); universe::position_type previous_pos; universe::position_type next_pos; compute_neighboor (that.get_bottom_left(),previous_pos,next_pos); claw::math::line_2d<universe::coordinate_type> line1 ( previous_pos, next_pos - previous_pos ); left_pos.y = line1.y_value(that.get_left()); compute_neighboor (that.get_bottom_right(),previous_pos,next_pos); claw::math::line_2d<universe::coordinate_type> line2 ( previous_pos, next_pos - previous_pos ); right_pos.y = line2.y_value(that.get_right()); claw::math::line_2d<universe::coordinate_type> line ( left_pos, right_pos - left_pos ); double angle = std::atan(line.direction.y / line.direction.x); that.set_contact_angle(angle); info.get_collision_repair().set_contact_normal (that, that.get_x_axis().get_orthonormal_anticlockwise()); } // bridge::apply_angle_to()