oldchase.txt
来自「FIRA 5V5比赛中一个机器人源代码 本科毕业设计做的」· 文本 代码 · 共 153 行
TXT
153 行
void CChaseAction::Go_Behind_Pos(Vector3D Destination,Robot *robot,int WhichRobot,int distx,int disty)
{
Vector3D offset;
offset.x = env->currentBall.pos.x - distx;
offset.y = env->currentBall.pos.y;
if(offset.x < 0){offset.x = 0;}
if(robot->pos.x >= (offset.x + 7) && robot->pos.x <= (offset.x - 7) && robot->pos.y >= (offset.y + 7) && robot->pos.y <= (offset.y - 7) )
{
robot->velocityLeft = 0;
robot->velocityRight = 0;
}
else
{
Position_Myro(offset,WhichRobot);
}
return;
}
void CChaseAction::Go_Above_Pos(Vector3D Destination,Robot *robot,int WhichRobot,int distx,int disty)
{
Vector3D offset;
offset.x = env->currentBall.pos.x;
offset.y = env->currentBall.pos.y + disty;
if(offset.x < 0){offset.x = 0;}
if(robot->pos.x >= (offset.x + 7) && robot->pos.x <= (offset.x - 7) && robot->pos.y >= (offset.y + 7) && robot->pos.y <= (offset.y - 7) )
{
robot->velocityLeft = 0;
robot->velocityRight = 0;
}
else
{
Position_Myro(offset,WhichRobot);
}
return;
}
void CChaseAction::Go_Below_Pos(Vector3D Destination,Robot *robot,int WhichRobot,int distx,int disty)
{
Vector3D offset;
offset.x = env->currentBall.pos.x;
offset.y = env->currentBall.pos.y - disty;
if(offset.x < 0){offset.x = 0;}
if(robot->pos.x >= (offset.x + 7) && robot->pos.x <= (offset.x - 7) && robot->pos.y >= (offset.y + 7) && robot->pos.y <= (offset.y - 7) )
{
robot->velocityLeft = 0;
robot->velocityRight = 0;
}
else
{
Position_Myro(offset,WhichRobot);
}
return;
}
void CChaseAction::Go_Front_Pos(Vector3D Destination,Robot *robot,int WhichRobot,int distx,int disty)
{
Vector3D offset;
offset.x = env->currentBall.pos.x + distx;
offset.y = env->currentBall.pos.y;
if(offset.x < 0){offset.x = 0;}
if(robot->pos.x >= (offset.x + 7) && robot->pos.x <= (offset.x - 7) && robot->pos.y >= (offset.y + 7) && robot->pos.y <= (offset.y - 7) )
{
robot->velocityLeft = 0;
robot->velocityRight = 0;
}
else
{
Position_Myro(offset,WhichRobot);
}
return;
}
void CChaseAction::Go_AboveNBehind_Pos(Vector3D Destination,Robot *robot,int WhichRobot,int distx,int disty)
{
Vector3D offset;
offset.x = env->currentBall.pos.x - distx;
offset.y = env->currentBall.pos.y + disty;
if(offset.x < 0){offset.x = 0;}
if(robot->pos.x >= (offset.x + 7) && robot->pos.x <= (offset.x - 7) && robot->pos.y >= (offset.y + 7) && robot->pos.y <= (offset.y - 7) )
{
robot->velocityLeft = 0;
robot->velocityRight = 0;
}
else
{
Position_Myro(offset,WhichRobot);
}
return;
}
void CChaseAction::Go_BelowNBehind_Pos(Vector3D Destination,Robot *robot,int WhichRobot,int distx,int disty)
{
Vector3D offset;
offset.x = env->currentBall.pos.x - distx;
offset.y = env->currentBall.pos.y - disty;
if(offset.x < 0){offset.x = 0;}
if(robot->pos.x >= (offset.x + 7) && robot->pos.x <= (offset.x - 7) && robot->pos.y >= (offset.y + 7) && robot->pos.y <= (offset.y - 7) )
{
robot->velocityLeft = 0;
robot->velocityRight = 0;
}
else
{
Position_Myro(offset,WhichRobot);
}
return;
}
void CChaseAction::Go_AboveNFront_Pos(Vector3D Destination,Robot *robot,int WhichRobot,int distx,int disty)
{
Vector3D offset;
offset.x = env->currentBall.pos.x + distx;
offset.y = env->currentBall.pos.y + disty;
if(offset.x < 0){offset.x = 0;}
if(robot->pos.x >= (offset.x + 7) && robot->pos.x <= (offset.x - 7) && robot->pos.y >= (offset.y + 7) && robot->pos.y <= (offset.y - 7) )
{
robot->velocityLeft = 0;
robot->velocityRight = 0;
}
else
{
Position_Myro(offset,WhichRobot);
}
return;
}
void CChaseAction::Go_BelowNFront_Pos(Vector3D Destination,Robot *robot,int WhichRobot,int distx,int disty)
{
Vector3D offset;
offset.x = env->currentBall.pos.x + distx;
offset.y = env->currentBall.pos.y - disty;
if(offset.x < 0){offset.x = 0;}
if(robot->pos.x >= (offset.x + 7) && robot->pos.x <= (offset.x - 7) && robot->pos.y >= (offset.y + 7) && robot->pos.y <= (offset.y - 7) )
{
robot->velocityLeft = 0;
robot->velocityRight = 0;
}
else
{
Position_Myro(offset,WhichRobot);
}
return;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?