📄 robot.c
字号:
#include "Robot.h"
#include "string.h"
////////////////////////////////////////////////////////////////////
//为全局变量分配空间
struct Map map;
struct ScannedRobotEvent scannedRobotEvent;
struct BulletHitEvent bulletHitEvent;
struct HitByBulletEvent hitByBulletEvent;
struct HitRobotEvent hitRobotEvent;
struct HitWallEvent hitWallEvent;
struct RobotDeathEvent robotDeathEvent;
struct BeginEvent beginEvent;
struct FinishEvent finishEvent;
struct OvertimeEvent overtimeEvent;
//只在此文件中可见
static long time;
static int currentRound;
static int totalRounds;
static double energy;
static double score;
static int others;
//输出缓冲区
static char output[100];
///////////////////////////////////////////////////////////////////////
/**
* 在控制台输出信息
*/
void println(char * s)
{
if( strlen(s) + strlen(output) + 2 >= 100 ) return;
strcat(output, s );
strcat(output,"\n");
}
/**
* 得到当前输出
*/
char * getOutput()
{
return output;
}
///////////////////////////////////////////////////////////////////////
// 这些函数返回一些关于机器人当前状态的信息
/*
* 得到当前时间
*/
long getTime()
{
return time;
}
/*
* 得到当前的比赛轮数
*/
int getCurrentRound()
{
return currentRound;
}
/*
* 得到总的比赛轮数
*/
int getTotalRounds()
{
return totalRounds;
}
/*
* 得到剩余能量
*/
double getEnergy()
{
return energy;
}
/*
* 得到当前的比赛得分
*/
double getScore()
{
return score;
}
/*
* 得到当前敌人总数
*/
int getOthers()
{
return others;
}
////////////////////////////////////////////////////////////////////
// 这些函数由系统调用,设置一些关于机器人当前状态的信息
/*
* 设置当前时间
*/
void setTime(long t)
{
time = t;
//清空缓冲区
output[0] = 0;
}
/*
* 设置当前的比赛轮数
*/
void setCurrentRound(int r)
{
currentRound = r;
}
/*
* 设置总的比赛轮数
*/
void setTotalRounds(int t)
{
totalRounds = t;
}
/*
* 设置剩余能量
*/
void setEnergy(double e)
{
energy = e;
}
/*
* 设置当前的比赛得分
*/
void setScore(double s)
{
score = s;
}
/*
* 设置当前敌人总数
*/
void setOthers(int o)
{
others = o;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -