This commit is contained in:
Xi Xu committed 2023-11-02 17:15:43 +08:00
commit 8b0e2733ef
1 file changed
+25 -25
+25 -25
View File
@@ -22,30 +22,30 @@ extern int nKick;
#define G_BOUND_BOUND 10
// 罚球
void CStrategySystem::Penalty() {
srand(time(nullptr));
int x = rand() % 2;
// 简单直线函数点球,向上射终点为(60,313),向下射终点为(60,505);
int k, b;
// 1往上射
if (x) {
k = (ball.position.y - 313) / (ball.position.x - 60);
b = 313 - 60 * k;
if (home1.position.x <= (ball.position.x + 16) && home1.position.x >= (ball.position.x + 16 - 1) && home1.position.y >= ((ball.position.x + 16) * k + b) - 1 && home1.position.y <= (ball.position.x + 16) * k + b)
Direction(HOME1, ball.position); // 跟踪球射门
else
Position(HOME1, CPoint(ball.position.x + 16 /*球每次更新位置,则将机器人放到函数直线上与球不同位置上,下一周期在踢球*/, (ball.position.x + 16) * k + b)); // 机器人最开始不在范围,则移动到指定位置
}
// 往下射
else {
k = (ball.position.y - 505) / (ball.position.x - 60);
b = 505 - 60 * k;
if (home1.position.x <= (ball.position.x + 16) && home1.position.x >= (ball.position.x + 16) - 1 && home1.position.y >= ((ball.position.x + 16) * k + b) - 1 && home1.position.y <= (ball.position.x + 16) * k + b)
Direction(HOME1, ball.position); // 跟踪球射门
else
Position(HOME1, CPoint(ball.position.x + 16, /*球每次更新位置,则将机器人放到函数直线上与球不同位置上,下一周期在踢球*/ (ball.position.x + 16) * k + b)); // 机器人最开始不在范围,则移动到指定位置
}
}
// void CStrategySystem::Penalty() {
// srand(time(nullptr));
// int x = rand() % 2;
// // 简单直线函数点球,向上射终点为(60,313),向下射终点为(60,505);
// int k, b;
// // 1往上射
// if (x) {
// k = (ball.position.y - 313) / (ball.position.x - 60);
// b = 313 - 60 * k;
// if (home1.position.x <= (ball.position.x + 16) && home1.position.x >= (ball.position.x + 16 - 1) && home1.position.y >= ((ball.position.x + 16) * k + b) - 1 && home1.position.y <= (ball.position.x + 16) * k + b)
// Direction(HOME1, ball.position); // 跟踪球射门
// else
// Position(HOME1, CPoint(ball.position.x + 16 /*球每次更新位置,则将机器人放到函数直线上与球不同位置上,下一周期在踢球*/, (ball.position.x + 16) * k + b)); // 机器人最开始不在范围,则移动到指定位置
// }
// // 往下射
// else {
// k = (ball.position.y - 505) / (ball.position.x - 60);
// b = 505 - 60 * k;
// if (home1.position.x <= (ball.position.x + 16) && home1.position.x >= (ball.position.x + 16) - 1 && home1.position.y >= ((ball.position.x + 16) * k + b) - 1 && home1.position.y <= (ball.position.x + 16) * k + b)
// Direction(HOME1, ball.position); // 跟踪球射门
// else
// Position(HOME1, CPoint(ball.position.x + 16, /*球每次更新位置,则将机器人放到函数直线上与球不同位置上,下一周期在踢球*/ (ball.position.x + 16) * k + b)); // 机器人最开始不在范围,则移动到指定位置
// }
// }
// 争球
void CStrategySystem::Freeball() {
@@ -128,7 +128,7 @@ void CStrategySystem::Shot(int which) {
shot1(which);*/
// if ()
// shot2();
}
}
void CStrategySystem::shot1(int which, double o) { // 直射
Robot2 *robot;