firefirst.c
来自「偶然收集到的一个C语言源码」· C语言 代码 · 共 33 行
C
33 行
#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 + =
减小字号Ctrl + -
显示快捷键?