tracker.cpp

来自「AI-CODE坦克机器人 《C++语言学习利器 —AI-CODE坦克机器人》-」· C++ 代码 · 共 28 行

CPP
28
字号
#include <airobot/cpp/SimpleRobot.hpp>

class Tracker : public SimpleRobot
{

public:
/**
   * 每个单位时间都会触发
   */
void onTick(TickAction* action){
	Bot* opponent = getFirstOpponent();
	if(opponent==NULL) return;
	moveTo(opponent->x, opponent->y);
	if(opponent->getLocation()->distance(getLocation())<150)
		{
			fire(opponent->getLocation(), 2);
		}
};

/**
 * 机器人程序入口
 */
int main(int argC, char* argV[])
{
	Robot* robot = new Tracker();
	return startup(argC, argV, robot);
}							

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?