supercenter.cpp
来自「AI-CODE坦克机器人 《C++语言学习利器 —AI-CODE坦克机器人》-」· C++ 代码 · 共 29 行
CPP
29 行
#include <airobot/cpp/SimpleRobot.hpp>
/**
* 这是一个向战场中心点运动的
* @author tts
*/
class SuperCenter : public SimpleRobot
{
public:
///////////////////////////////////////////////////////////////
//正确的实现方案
void onTick(TickAction* action)
{
double halfWidth = getCourtWidth()/2; //计算场地中心宽
double halfHeigth = getCourtHeight()/2; //计算场地中心高
//计算中心点坐标,并转为二维空间点
Point2D center = new Point2D.Double(halfWidth,halfHeigth);
moveTo(center);
}
//启动机器人程序
int main(int argC, char* argV[])
{
Robot* robot = new Walls();
return startup(argC, argV, robot);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?