?? bridge.c
字號:
#include "Bridge.h"
#include "Robot.h"
//////////////////////////////////////////////////////////////
//robot
void __cdecl localWork()
{
work();
}
//事件處理函數,相應事件發生時被調用一次
/*
* 當雷達掃描到敵人時觸發
*/
void __cdecl localOnScannedRobot(
long t, const char * n, double x,
double y, double h, double v, double e )
{
scannedRobotEvent.time = t;
scannedRobotEvent.name = n;
scannedRobotEvent.x = x;
scannedRobotEvent.y = y;
scannedRobotEvent.heading = h;
scannedRobotEvent.velocity = v;
scannedRobotEvent.energy = e;
onScannedRobot();
}
/*
* 當打中某個敵人時觸發
*/
void __cdecl localOnBulletHit(
long t, double p, const char* n, double x, double y)
{
bulletHitEvent.time = t;
bulletHitEvent.power = p;
bulletHitEvent.name = n;
bulletHitEvent.x = x;
bulletHitEvent.y = y;
onBulletHit();
}
/*
* 當被敵人打中時觸發
*/
void __cdecl localOnHitByBullet(long t, const char * n, double p)
{
hitByBulletEvent.time = t;
hitByBulletEvent.name = n;
hitByBulletEvent.power = p;
onHitByBullet();
}
/*
* 當撞到其它敵人時觸發
*/
void __cdecl localOnHitRobot(long t, const char * n, double x, double y)
{
hitRobotEvent.time = t;
hitRobotEvent.name = n;
hitRobotEvent.x = x;
hitRobotEvent.y = y;
onHitRobot();
}
/*
* 當某個敵人死時觸發
*/
void __cdecl localOnRobotDeath(long t, const char * n)
{
robotDeathEvent.time = t;
robotDeathEvent.name = n;
onRobotDeath();
}
/*
* 當撞到墻時觸發
*/
void __cdecl localOnHitWall(long t)
{
hitWallEvent.time = t;
onHitWall();
}
/*
* 當開始一輪新的戰斗時觸發
*/
void __cdecl localOnBegin(long t)
{
beginEvent.time = t;
onBegin();
}
/*
* 當一輪戰斗結束時觸發
*/
void __cdecl localOnFinish(long t)
{
finishEvent.time = t;
onFinish();
}
/*
* 當機器人執行操作超時時觸發
*/
void __cdecl localOnOvertime(long t)
{
overtimeEvent.time = t;
onOvertime();
}
////////////////////////////////////////////////////////////////////
// 這些函數由系統調用,設置一些關于機器人當前狀態的信息/*
/*
* 設置當前時間
*/
void __cdecl localSetTime(long t)
{
setTime(t);
}
/*
* 設置當前的比賽輪數
*/
void __cdecl localSetCurrentRound(int r)
{
setCurrentRound(r);
}
/*
* 設置總的比賽輪數
*/
void __cdecl localSetTotalRounds(int t)
{
setTotalRounds(t);
}
/*
* 設置剩余能量
*/
void __cdecl localSetEnergy(double e)
{
setEnergy(e);
}
/*
* 設置當前的比賽得分
*/
void __cdecl localSetScore(double s)
{
setScore(s);
}
/*
* 設置當前敵人總數
*/
void __cdecl localSetOthers(int o)
{
setOthers(o);
}
/**
* 設置地圖
*/
void __cdecl localSetMap(int w, int h)
{
map.height = w;
map.width = h;
}
/**
* 得到當前輸出
*/
char * __cdecl localGetOutput()
{
return getOutput();
}
////////////////////////////////////////////////////////////////////////////
//body
/*
* 得到用戶想用轉動的角度的剩余量
* 比如:上個單位時間,用戶用turn(Math.toRadians(15))讓車身旋轉15度
* 但是車身的最大旋轉速度為10度/單位時間,所以這個單位時間調用getTurnRemaining()
* 會得到返回值0.08754(5/180*PI),說明還有5度需要轉動,如果用戶此時沒有新的turn函數的調用
* 那么下個單位時間車身將會只轉動5度
*/
double __cdecl localGetBodyTurnRemaining()
{
return getBodyTurnRemaining();
}
/*
* 得到用戶想要到達的速度
*/
double __cdecl localGetBodyPreferVelocity()
{
return getBodyPreferVelocity();
}
// 這些函數由系統調用,設置一些關于機器人當前狀態的信息
/*
* 設置當前的坐標
*/
void __cdecl localSetBodyPosition(double x, double y)
{
setBodyPosition(x,y);
}
/*
* 設置當前的車身方向
*/
void __cdecl localSetBodyHeading(double h)
{
setBodyHeading(h);
}
/*
* 設置當前的移動速度
*/
void __cdecl localSetBodyVelocity(double v)
{
setBodyVelocity(v);
}
//////////////////////////////////////////////////////////////////////
//gun
// 得到用戶想用轉動的度數的剩余量
double __cdecl localGetGunTurnRemaining()
{
return getGunTurnRemaining();
}
// 得到用戶將要發射的炮彈的能量
double __cdecl localGetFirePower()
{
return getFirePower();
}
// 設置當前方向
void __cdecl localSetGunHeading(double h)
{
setGunHeading(h);
}
// 設置發單的準備時間
void __cdecl localSetGunPrepareTime(long t)
{
setGunPrepareTime(t);
}
////////////////////////////////////////////////////////////////////////
//radar
/*
* 得到用戶想用轉動的角度的剩余量
* 比如:上個單位時間,用戶用turn(Math.toRadians(50))讓雷達旋轉50度
* 但是雷達的最大旋轉速度為45度/單位時間,所以這個單位時間調用getTurnRemaining()
* 會得到返回值0.08754(5/180*PI),說明還有5度需要轉動,如果用戶此時沒有新的turn函數的調用
* 那么下個單位時間雷達將會只轉動5度
*/
double __cdecl localGetRadarTurnRemaining()
{
return getRadarTurnRemaining();
}
/*
* 設置當前方向
*/
void __cdecl localSetRadarHeading(double heading)
{
setRadarHeading(heading);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -