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