getRadarHeading 得到雷达的角度
public double getRadarHeading()
Returns the direction that the robot's radar is facing, in degrees. The value returned will be between 0 and 360 (is excluded).
Note that the heading in Robocode is like a compass, where 0 means North, 90 means East, 180 means South, and 270 means West.
得到雷达正对着的方向,用角度表示。返回值在0到360(不含360)之间。
请注意在机器人编程中指向就像一个罗盘,在这里0表示正北,90表示正东,180表示正南,270表示正西。
Returns:
the direction that the robot's radar is facing, in degrees.
返回值:
雷达正对着的方向,用角度表示
See Also:
getHeading(), getGunHeading()
--------------------------------------------------------------------------------
getRoundNum 得到当前轮数
public int getRoundNum()
Returns the current round number (0 to getNumRounds() - 1) of the battle.
返回当前回合是第几回合,值的范围是[0, to getNumRounds() - 1],闭区间。
Returns:
the current round number of the battle
返回值:
当前的回合数
See Also:
getNumRounds()
--------------------------------------------------------------------------------
getTime 得到时间
public long getTime()
Returns the game time of the current round, where the time is equal to the current turn in the round.
A battle consists of multiple rounds.
返回当前回合的时间,这个值和这个回合的turn值是一样的。
Time is reset to 0 at the beginning of every round.
在每一个回合时间被重新设置为0。
Returns:
the game time/turn of the current round.
返回值:
当前回合的时间。
--------------------------------------------------------------------------------
getVelocity 得到速度
public double getVelocity()
Returns the velocity of the robot measured in pixels/turn.
The maximum velocity of a robot is defined by Rules.MAX_VELOCITY (8 pixels / turn).
返回这个机器人的速度,以像素/一个时间单位为单位。(译者注:在robocode中,turn表示为一个单位,可以认是一声滴答的时间)。
Returns:
the velocity of the robot measured in pixels/turn.
返回值:
机器人的速度,以像素/单位时间为单位。
See Also:
Rules.MAX_VELOCITY
--------------------------------------------------------------------------------
onBulletHit 当击中对方时
public void onBulletHit(BulletHitEvent event)
This method is called when one of your bullets hits another robot. You should override it in your robot if you want to be informed of this event.
当你的子弹击中对方时就会调用这个方法。如果你想在子弹击中对方时作处理的话,你应当重写这个方法。
Example:
例如:
public void onBulletHit(BulletHitEvent event) {
out.println("I hit " + event.getName() + "!");
}
Specified by:
onBulletHit in interface IBasicEvents
这个方法的原始定义在IBasicEvents中
Parameters:
event - the bullet-hit event set by the game
参数:
event - the bullet-hit 游戏自己设置的(译者:这应当是默认的参数吧)
See Also:
BulletHitEvent, Event
--------------------------------------------------------------------------------
onBulletHitBullet 当子弹击中子弹时
public void onBulletHitBullet(BulletHitBulletEvent event)
This method is called when one of your bullets hits another bullet. You should override it in your robot if you want to be informed of this event.
当你的子弹击中别人的子弹时这个方法会被调用。如果你想在此时作一些处理,你应当重写这个方法。
Example:
例如:
public void onBulletHitBullet(BulletHitBulletEvent event) {
out.println("I hit a bullet fired by " + event.getBullet().getName() + "!");
}
Specified by:
onBulletHitBullet in interface IBasicEvents
原始定义在IBasicEvents中
Parameters:
event - the bullet-hit-bullet event set by the game
参数是游戏默认参数。
See Also:
BulletHitBulletEvent, Event
--------------------------------------------------------------------------------
onBulletMissed 当子弹迷路时
public void onBulletMissed(BulletMissedEvent event)
This method is called when one of your bullets misses, i.e. hits a wall. You should override it in your robot if you want to be informed of this event.
当你的子弹迷路时就会调用这个方法,也就是说,此时你的子弹打到墙了。如果你想在此时做一些处理,你应当重写这个方法。
Example:
public void onBulletHit(BulletMissedEvent event) {
out.println("Drat, I missed.");
}
Specified by:
onBulletMissed in interface IBasicEvents
Parameters:
event - the bullet-missed event set by the game
参数是游戏默认的参数。
See Also:
BulletMissedEvent, Event
--------------------------------------------------------------------------------
onDeath 当死了的时候
public void onDeath(DeathEvent event)
This method is called if your robot dies.
You should override it in your robot if you want to be informed of this event. Actions will have no effect if called from this section. The intent is to allow
you to perform calculations or print something out when the robot is killed.
当你的机器人被消灭时这个方法会被调用。
如果你想在此时做一些处理,你应当重写这个方法。在这个区域写的所有的动作都没有任何效果。这个函数的目的是允许你在机器人死的时候计算或是打印一些数据。
Specified by:
onDeath in interface IBasicEvents
Parameters:
event - the death event set by the game
参数是游戏默认的参数。
See Also:
DeathEvent, Event