This commit is contained in:
xixu-me committed 2023-11-30 17:55:46 +08:00
1 parent 7f407cfb69
commit 42f34dae1e
2 files changed
+25 -18

No files matched your search

+24 -18
View File
@@ -2402,27 +2402,31 @@ int CStrategySystem::search2() // 查找在小区里的机器人
// 守门
void CStrategySystem::Goalie() {
if (is_start) {
ball.oldPosition = ball.position;
is_start = false;
}
int gx = ball.position.x >= 873 && (ball.position.y <= 217 || ball.position.y >= 607) || ball.position.x >= 950 ? 965 : 950;
int gy = int(((ball.position.y - ball.oldPosition.y) * 1.0 / (ball.position.x - ball.oldPosition.x) * 1.0) * gx + (ball.oldPosition.y - ((ball.position.y - ball.oldPosition.y) * 1.0 / (ball.position.x - ball.oldPosition.x) * 1.0) * ball.oldPosition.x) + 0.5);
if (ball.position.x > 515)
// if (ball.position.x < ball.oldPosition.x)
if (Distance(ball.position, ball.oldPosition) >= 5) {
if (gy < 313)
Direction(HGOALIE, CPoint(gx, 313));
else if (gy > 505)
Direction(HGOALIE, CPoint(gx, 505));
else
Direction(HGOALIE, CPoint(gx, gy));
}
else {
if (ball.position.y < 313)
Direction(HGOALIE, CPoint(gx, 313));
else if (ball.position.y > 505)
Direction(HGOALIE, CPoint(gx, 505));
else
Direction(HGOALIE, CPoint(gx, ball.position.y));
}
// if (ball.position.x < ball.oldPosition.x)
if (Distance(ball.position, ball.oldPosition) >= 5) {
if (gy < 313)
Direction(HGOALIE, CPoint(gx, 313));
else if (gy > 505)
Direction(HGOALIE, CPoint(gx, 505));
else
Direction(HGOALIE, CPoint(gx, gy));
}
else {
if (ball.position.y < 313)
Direction(HGOALIE, CPoint(gx, 313));
else if (ball.position.y > 505)
Direction(HGOALIE, CPoint(gx, 505));
else
Direction(HGOALIE, CPoint(gx, ball.position.y));
}
ball.oldPosition = ball.position;
@@ -3320,6 +3324,8 @@ CStrategySystem::CStrategySystem(int id) {
// Navigation.push_back(CPoint(515, 409));
// }
is_start = true;
pos = new CPoint[10];
rp = new RelPos[10];