robocode_API中文参考(java)

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

public double getBattleFieldHeight()
Returns the height of the current battlefield measured in pixels.
返回值为能像素为单位的当前战场的高度
Returns:
the height of the current battlefield measured in pixels.
Example:
比如: // Move the robot 100 pixels forward
将机器人向前移动 100 个像素 ahead(100);
// Afterwards, move the robot 50 pixels backward 然后,向后移动 50 个像素 ahead(-50);
Parameters:
参数: distance - the distance to move ahead measured in pixels. If this value is negative, the robot will move back instead of ahead
distanse-向前移动的距离,单位是像素。如果其值是负数,机器人会用向后来代 替向前。
返回机器人面对的方向,用角度表示。返回值的范围是 0 到 360 之间(不含 360)。
Note that the heading in Robocode is like a compass, where 0 means North, 90 means East, 180
means South, and 270 means West.
Returns: the X position of the robot.
See Also:
getY()
--------------------------------------------------------------------------------
getY 得到 Y 坐标 public double getY() Returns the Y position of the robot. (0,0) is at the bottom left of the battlefield. 返回值为机器人的 Y 坐标,(0,0)坐标在战场的左下角。(译者注:向右为 X 正向,向上为 Y 正向)。
getHeading
得到自己的方向
public double getHeading()
Returns the direction that the robot's body is facing, in degrees. The value returned will be
between 0 and 360 (is excluded).
-------------------------------------------------------------------rs:
参数: distance - the distance to move back measured in pixels. If this value is negative, the robot will move ahead instead of back.
This call executes immediately, and does not return until it is complete, i.e. when the remaining distance to move is 0. 这个函数会马上执行,并且直到完成了任务才返回,比如,当距离已前进完时。 If the robot collides with a wall, the move is complete, meaning that the robot will not move any further. If the robot collides with another robot, the move is complete if you are heading toward the other robot. 当机器人撞到墙时,动作也是完成了,意味着此时机器人将不再向前进。当你的机器人撞到 其它的机器人时,如果你是头部撞到其它的机器人时动作也就完成。 Note that both positive and negative values can be given as input, where negative values means that the robot is set to move forward instead of backward. 记住正数和负数都可以作为距离的值,当距离为负值时表示机器人向前进距离的绝对值个像 素。
See Also:
getHeight()
getName
返回自己的名字
public String getName() Returns the robot's name. 返回机器人自己的名字
Returns: the robot's name.
--------------------------------------------------------------------------------
distanse-向后移动的距离,单位是像素。如果其值是负数,机器人会用向前来代 替向后。
See Also:
可以参考: ahead(double), onHitWall(HitWallEvent), onHitRobot(HitRobotEvent)
getBattleFieldWidth 得到战场宽度 public double getBattleFieldWidth() Returns the width of the current battlefield measured in pixels. 返回值为以像素为单位表示的当前战场的宽度 Returns: the width of the current battlefield measured in pixels. -------------------------------------------------------------------------------getBattleFieldHeight 得到战场高度
robocode 部分 API 中文参考
ahead 向前
public void ahead(double distance) Immediately moves your robot ahead (forward) by distance measured in pixels. 马上将你的机器人向前移动 以 distance 指定的 多少个像素 This call executes immediately, and does not return until it is complete, i.e. when the remaining distance to move is 0. 这个函数会马上执行,并且直到完成了任务才返回,比如,当距离已前进完时。 If the robot collides with a wall, the move is complete, meaning that the robot will not move any further. If the robot collides with another robot, the move is complete if you are heading toward the other robot. 当机器人撞到墙时,动作也是完成了,意味着此时机器人将不再向前进。当你的机器人撞到 其它的机器人时,如果你是头部撞到其它的机器人时动作也就完成。 Note that both positive and negative values can be given as input, where negative values means that the robot is set to move backward instead of forward. 记住正数和负数都可以作为距离的值,当距离为负值时表示机器人向后退距离的绝对值个像 素。
getX 得到 X 坐标 public double getX() Returns the X position of the robot. (0,0) is at the bottom left of the battlefield. 返回值为机器人的 X 坐标,(0,0)坐标在战场的左下角。(译者注:向右为 X 正向,向上为 Y 正向)。
Example:
例如: // A basic robot that moves around in a square
一个在一个正方形里反复行走的基本的机器人 public void run() { while (true) { ahead(100); turnRight(90); } }
Specified by: run in interface Runnable 可以行走的时候才会行走。
Example:
比如: // Move the robot 100 pixels backward
将机器人向后移动 100 个像素 back(100);
// Afterwards, move the robot 50 pixels forward 然后,向前移动 50 个像素 ahead(-50);
记住在机器人软件中的坐标系就像一个罗盘,0 表示正北,90 表示正东,180 表示正南,270
表示正西。
Returns: the direction that the robot's body is facing, in degrees. 返回机器人面对的方向,用角度表示
See Also:
getGunHeading(), getRadarHeading()
Returns: the Y position of the robot.
See Also:
getX()
run public void run() The main method in every robot. You must override this to set up your robot's basic behavior. 在每个机器人中的主方法。为了你的机器人有一些基本行为,你必须重写这个方法。
See Also:
getWidth() -------------------------------------------------------------------------------getWidth public double getWidth() Returns the width of the robot measured in pixels. 返回机器人自己的宽度,单位为像素。 Returns: the width of the robot measured in pixels.
getHeight public double getHeight() Returns the height of the robot measured in pixels. 返回机器人自己的高度,单位为像素。 Returns: the height of the robot measured in pixels.
See Also:
可以参考:
back(double), onHitWall(HitWallEvent), onHitRobot(HitRobotEvent) back 向后 public void back(double distance) Immediately moves your robot backward by distance measured in pixels. 马上将你的机器人向后移动 以 distance 指定的 多少个像素
相关文档
最新文档