⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 firefirst.c

📁 偶然收集到的一个C语言源码
💻 C
字号:
#include <airobot/c/SimpleRobot.h>
double opponentVelocity;  /* 对手的速度 */
	double power = 1;        /* 炮弹的能量 */
	double bulletVelocity;     /* 炮弹的速度 */
	double headingAB;       /* 连线AB的方向角*/
	double headingAC;       /* 连线AC的方向角*/
	double bearingCAB;      /* ∠CAB */
	double sinCAB;          /* ∠CAB的正弦值*/
	double angleACB;        /* ∠ACB的值*/
	double headingCB;       /* CB连线的方向角*/

	/**
	 * 每个单位时间都会触发
	 */
	public void onTick(TickAction action){
		struct Bot* bot = getFirstOpponent();
opponentVelocity = bot->velocity;
		bulletVelocity = 20 - 3*power;         /*求炮弹的速度*/
		headingAB = bot->heading;/*求连线AB的方向角*/
	    headingAC=heading(bot->x,box->y,getX(),getY());/*求连线AC的方向角*/
		bearingCAB = bearing(headingAB, headingAC);/* 求∠CAB */
		sinCAB = sin(bearingCAB);/* 求∠CAB的正弦值*/
        /* 求∠ACB的值*/
	angleACB = asin(opponentVelocity * sinCAB / bulletVelocity);		 headingCB = headingAC + PI - angleACB;
	    fire(headingCB,power);
	}
//启动机器人程序
int main(int argC, char* argV[])
{
	tickHook = onTick;
	return startup(argC, argV);
}

⌨️ 快捷键说明

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