int Area::addToSegment(Segment & s) const { if (!checkIntersects(s)) { return -1; } return s.addArea(this); }
void Area::updateToSegment(Segment & s) const { if (!checkIntersects(s)) { s.removeArea(this); return; } if (s.updateArea(this) != 0) { s.addArea(this); } }
WFMath::Polygon<2> Area::clipToSegment(const Segment& s) const { // box reject if (!checkIntersects(s)) return WFMath::Polygon<2>(); WFMath::AxisBox<2> segBox(s.getRect()); WFMath::Polygon<2> clipped = sutherlandHodgmanKernel(m_shape, TopClip(segBox.lowCorner().y())); clipped = sutherlandHodgmanKernel(clipped, BottomClip(segBox.highCorner().y())); clipped = sutherlandHodgmanKernel(clipped, LeftClip(segBox.lowCorner().x())); clipped = sutherlandHodgmanKernel(clipped, RightClip(segBox.highCorner().x())); return clipped; }
Area::ring Area::clipToSegment(Segment const & s) const { // box reject if (!checkIntersects(s)) { return Area::ring(); } boost::geometry::model::box<point> seg_box = s.getRect(); std::vector<ring> clipped; boost::geometry::intersection(m_shape, seg_box, clipped); assert(clipped.size() > 0); return clipped[0]; }
void GameProcess::Update() { //cout << "Timer" << endl; restartSnake(); pastX = snake[num - 1].x; pastY = snake[num - 1].y; for (int i = num; i > 0; --i) { snake[i].x = snake[i - 1].x; snake[i].y = snake[i - 1].y; } if (dir == 0) snake[0].y += 1; if (dir == 1) snake[0].x += 1; if (dir == 2) snake[0].y -= 1; if (dir == 3) snake[0].x -= 1; if (snake[0].x > N - 1) snake[0].x = 0; if (snake[0].x < 0) snake[0].x = N - 1; if (snake[0].y > M - 1) snake[0].y = 0; if (snake[0].y < 0) snake[0].y = M - 1; checkIntersects(); //changeCamera(); cout << "Camera x: " << camera->getPosition().x << " " << camera->getPosition().y << " " << camera->getPosition().z << endl; changeCamera(); //cout << "EAT " << eat.x << " " << eat.y << endl; }
void Area::removeFromSegment(Segment & s) const { if (checkIntersects(s)) { s.removeArea(this); } }