|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrobocode._RobotBase
robocode.JuniorRobot
public class JuniorRobot
This is the simplest robot type, which is simpler than the Robot
and
AdvancedRobot
classes. The JuniorRobot has a simplified model, in
purpose of teaching programming skills to inexperienced in programming
students. The simplified robot model will keep player from overwhelming of
Robocode's rules, programming syntax and programming concept.
Robot
,
AdvancedRobot
,
TeamRobot
,
Droid
Field Summary | |
---|---|
static int |
black
The color black (0x000000) |
static int |
blue
The color blue (0x0000FF) |
static int |
brown
The color brown (0x8B4513) |
int |
energy
Current energy of this robot, where 100 means full energy and 0 means no energy (dead). |
int |
fieldHeight
Contains the height of the battlefield. |
int |
fieldWidth
Contains the width of the battlefield. |
static int |
gray
The color gray (0x808080) |
static int |
green
The color green (0x008000) |
int |
gunBearing
Current gun heading angle of this robot compared to its body (in degrees). |
int |
gunHeading
Current gun heading angle of this robot (in degrees). |
boolean |
gunReady
Flag specifying if the gun is ready to fire, i.e. gun heat <= 0. |
int |
heading
Current heading angle of this robot (in degrees). |
int |
hitByBulletAngle
Latest angle from where this robot was hit by a bullet (in degrees). |
int |
hitByBulletBearing
Latest angle from where this robot was hit by a bullet (in degrees) compared to the body of this robot. |
int |
hitRobotAngle
Latest angle where this robot has hit another robot (in degrees). |
int |
hitRobotBearing
Latest angle where this robot has hit another robot (in degrees) compared to the body of this robot. |
int |
hitWallAngle
Latest angle where this robot has hit a wall (in degrees). |
int |
hitWallBearing
Latest angle where this robot has hit a wall (in degrees) compared to the body of this robot. |
static int |
orange
The color orange (0xFFA500) |
int |
others
Current number of other robots on the battle field. |
static int |
purple
The color purple (0x800080) |
static int |
red
The color red (0xFF0000) |
int |
robotX
Current horizontal location of this robot (in pixels). |
int |
robotY
Current vertical location of this robot (in pixels). |
int |
scannedAngle
Current angle to the scanned nearest other robot (in degrees). |
int |
scannedBearing
Current angle to the scanned nearest other robot (in degrees) compared to the body of this robot. |
int |
scannedDistance
Current distance to the scanned nearest other robot (in pixels). |
int |
scannedEnergy
Current energy of scanned nearest other robot. |
int |
scannedHeading
Current heading of the scanned nearest other robot (in degrees). |
int |
scannedVelocity
Current velocity of the scanned nearest other robot. |
static int |
white
The color white (0xFFFFFF) |
static int |
yellow
The color yellow (0xFFFF00) |
Fields inherited from class robocode._RobotBase |
---|
out |
Constructor Summary | |
---|---|
JuniorRobot()
|
Method Summary | |
---|---|
void |
ahead(int distance)
Moves this robot forward by pixels. |
void |
back(int distance)
Moves this robot backward by pixels. |
void |
bearGunTo(int angle)
Turns the gun to the specified angle (in degrees) relative to body of this robot. |
void |
doNothing()
Skips a turn. |
void |
doNothing(int turns)
Skips the specified number of turns. |
void |
fire()
Fires a bullet with the default power of 1. |
void |
fire(double power)
Fires a bullet with the specified bullet power, which is between 0.1 and 3 where 3 is the maximum bullet power. |
IBasicEvents |
getBasicEventListener()
Do not call this method! |
Runnable |
getRobotRunnable()
Do not call this method! |
void |
onHitByBullet()
This event methods is called from the game when this robot has been hit by another robot's bullet. |
void |
onHitRobot()
This event methods is called from the game when a bullet from this robot has hit another robot. |
void |
onHitWall()
This event methods is called from the game when this robot has hit a wall. |
void |
onScannedRobot()
This event method is called from the game when the radar detects another robot. |
void |
run()
The main method in every robot. |
void |
setColors(int bodyColor,
int gunColor,
int radarColor)
Sets the colors of the robot. |
void |
setColors(int bodyColor,
int gunColor,
int radarColor,
int bulletColor,
int scanArcColor)
Sets the colors of the robot. |
void |
turnAheadLeft(int distance,
int degrees)
Moves this robot forward by pixels and turns this robot left by degrees at the same time. |
void |
turnAheadRight(int distance,
int degrees)
Moves this robot forward by pixels and turns this robot right by degrees at the same time. |
void |
turnBackLeft(int distance,
int degrees)
Moves this robot backward by pixels and turns this robot left by degrees at the same time. |
void |
turnBackRight(int distance,
int degrees)
Moves this robot backward by pixels and turns this robot right by degrees at the same time. |
void |
turnGunLeft(int degrees)
Turns the gun left by degrees. |
void |
turnGunRight(int degrees)
Turns the gun right by degrees. |
void |
turnGunTo(int angle)
Turns the gun to the specified angle (in degrees). |
void |
turnLeft(int degrees)
Turns this robot left by degrees. |
void |
turnRight(int degrees)
Turns this robot right by degrees. |
void |
turnTo(int angle)
Turns this robot to the specified angle (in degrees). |
Methods inherited from class robocode._RobotBase |
---|
finalize, setOut, setPeer |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface robocode.robotinterfaces.IBasicRobot |
---|
setOut, setPeer |
Field Detail |
---|
public static final int black
public static final int white
public static final int red
public static final int orange
public static final int yellow
public static final int green
public static final int blue
public static final int purple
public static final int brown
public static final int gray
public int fieldWidth
fieldWidth
public int fieldHeight
fieldWidth
public int others
public int energy
public int robotX
robotY
public int robotY
robotX
public int heading
turnLeft(int)
,
turnRight(int)
,
turnTo(int)
,
turnAheadLeft(int, int)
,
turnAheadRight(int, int)
,
turnBackLeft(int, int)
,
turnBackRight(int, int)
public int gunHeading
gunBearing
,
turnGunLeft(int)
,
turnGunRight(int)
,
turnGunTo(int)
,
bearGunTo(int)
public int gunBearing
gunHeading
,
turnGunLeft(int)
,
turnGunRight(int)
,
turnGunTo(int)
,
bearGunTo(int)
public boolean gunReady
true
means that the gun is able to fire; false
means that the gun cannot fire yet as it still needs to cool down.
fire()
,
fire(double)
public int scannedDistance
onScannedRobot()
event is active.
onScannedRobot()
,
scannedAngle
,
scannedBearing
,
scannedEnergy
,
scannedVelocity
,
scannedHeading
public int scannedAngle
onScannedRobot()
event is active.
onScannedRobot()
,
scannedDistance
,
scannedBearing
,
scannedEnergy
,
scannedVelocity
,
scannedHeading
public int scannedBearing
onScannedRobot()
event is active.
onScannedRobot()
,
scannedDistance
,
scannedAngle
,
scannedEnergy
,
scannedVelocity
,
scannedHeading
public int scannedVelocity
onScannedRobot()
event is active.
onScannedRobot()
,
scannedDistance
,
scannedAngle
,
scannedBearing
,
scannedEnergy
,
scannedHeading
public int scannedHeading
onScannedRobot()
event is active.
onScannedRobot()
,
scannedDistance
,
scannedAngle
,
scannedBearing
,
scannedEnergy
,
scannedVelocity
public int scannedEnergy
onScannedRobot()
event is active.
onScannedRobot()
,
scannedDistance
,
scannedAngle
,
scannedBearing
,
scannedVelocity
public int hitByBulletAngle
onHitByBullet()
event is active.
onHitByBullet()
,
hitByBulletBearing
public int hitByBulletBearing
onHitByBullet()
event is active.
onHitByBullet()
,
hitByBulletAngle
public int hitRobotAngle
onHitRobot()
event is active.
onHitRobot()
,
hitRobotBearing
public int hitRobotBearing
onHitRobot()
event is active.
onHitRobot()
,
hitRobotAngle
public int hitWallAngle
onHitWall()
event is active.
onHitWall()
,
hitWallBearing
public int hitWallBearing
onHitWall()
event is active.
onHitWall()
,
hitWallAngle
Constructor Detail |
---|
public JuniorRobot()
Method Detail |
---|
public void ahead(int distance)
distance
- the amount of pixels to move forwardback(int)
,
robotX
,
robotY
public void back(int distance)
distance
- the amount of pixels to move backwardahead(int)
,
robotX
,
robotY
public void bearGunTo(int angle)
angle
- the angle to turn the gun to relative to the body of this robotgunHeading
,
gunBearing
,
turnGunLeft(int)
,
turnGunRight(int)
,
turnGunTo(int)
public void doNothing()
doNothing(int)
public void doNothing(int turns)
turns
- the number of turns to skipdoNothing()
public void fire()
gunReady
public void fire(double power)
power
- between 0.1 and 3gunReady
public final IBasicEvents getBasicEventListener()
IBasicEvents
listener.
getBasicEventListener
in interface IBasicRobot
null
if this robot should
not receive the notifications.public final Runnable getRobotRunnable()
run()
method of your robot, where the program
of your robot is implemented.
getRobotRunnable
in interface IBasicRobot
Runnable.run()
public void onHitByBullet()
hitByBulletAngle
and hitByBulletBearing
fields values
are automatically updated.
hitByBulletAngle
,
hitByBulletBearing
public void onHitRobot()
hitRobotAngle
and hitRobotBearing
fields values are automatically updated.
hitRobotAngle
,
hitRobotBearing
public void onHitWall()
hitWallAngle
and hitWallBearing
fields values are automatically updated.
hitWallAngle
,
hitWallBearing
public void onScannedRobot()
scannedDistance
,
scannedAngle
, scannedBearing
, and scannedEnergy
field values are automatically updated.
scannedDistance
,
scannedAngle
,
scannedBearing
,
scannedEnergy
public void run()
// A basic robot that moves around in a square public void run() { ahead(100); turnRight(90); }This method is automatically re-called when it has returned.
run
in interface Runnable
public void setColors(int bodyColor, int gunColor, int radarColor)
bodyColor
- the RGB color value for the bodygunColor
- the RGB color value for the gunradarColor
- the RGB color value for the radarsetColors(int, int, int, int, int)
public void setColors(int bodyColor, int gunColor, int radarColor, int bulletColor, int scanArcColor)
bodyColor
- the RGB color value for the bodygunColor
- the RGB color value for the gunradarColor
- the RGB color value for the radarbulletColor
- the RGB color value for the bulletsscanArcColor
- the RGB color value for the scan arcsetColors(int, int, int)
public void turnAheadLeft(int distance, int degrees)
distance
- the amount of pixels to move forwarddegrees
- the amount of degrees to turn to the leftheading
,
robotX
,
robotY
,
turnLeft(int)
,
turnRight(int)
,
turnTo(int)
,
turnAheadRight(int, int)
,
turnBackLeft(int, int)
,
turnBackRight(int, int)
public void turnAheadRight(int distance, int degrees)
distance
- the amount of pixels to move forwarddegrees
- the amount of degrees to turn to the rightheading
,
robotX
,
robotY
,
turnLeft(int)
,
turnRight(int)
,
turnTo(int)
,
turnAheadLeft(int, int)
,
turnBackLeft(int, int)
,
turnBackRight(int, int)
public void turnBackLeft(int distance, int degrees)
distance
- the amount of pixels to move backwarddegrees
- the amount of degrees to turn to the leftheading
,
robotX
,
robotY
,
turnLeft(int)
,
turnRight(int)
,
turnTo(int)
,
turnAheadLeft(int, int)
,
turnAheadRight(int, int)
,
turnBackRight(int, int)
public void turnBackRight(int distance, int degrees)
distance
- the amount of pixels to move backwarddegrees
- the amount of degrees to turn to the rightheading
,
robotX
,
robotY
,
turnLeft(int)
,
turnRight(int)
,
turnTo(int)
,
turnAheadLeft(int, int)
,
turnAheadRight(int, int)
,
turnBackLeft(int, int)
public void turnGunLeft(int degrees)
degrees
- the amount of degrees to turn the gun to the leftgunHeading
,
gunBearing
,
turnGunRight(int)
,
turnGunTo(int)
,
bearGunTo(int)
public void turnGunRight(int degrees)
degrees
- the amount of degrees to turn the gun to the rightgunHeading
,
gunBearing
,
turnGunLeft(int)
,
turnGunTo(int)
,
bearGunTo(int)
public void turnGunTo(int angle)
angle
- the angle to turn the gun togunHeading
,
gunBearing
,
turnGunLeft(int)
,
turnGunRight(int)
,
bearGunTo(int)
public void turnLeft(int degrees)
degrees
- the amount of degrees to turn to the leftheading
,
turnRight(int)
,
turnTo(int)
,
turnAheadLeft(int, int)
,
turnAheadRight(int, int)
,
turnBackLeft(int, int)
,
turnBackRight(int, int)
public void turnRight(int degrees)
degrees
- the amount of degrees to turn to the rightheading
,
turnLeft(int)
,
turnTo(int)
,
turnAheadLeft(int, int)
,
turnAheadRight(int, int)
,
turnBackLeft(int, int)
,
turnBackRight(int, int)
public void turnTo(int angle)
angle
- the angle to turn this robot toheading
,
turnLeft(int)
,
turnRight(int)
,
turnAheadLeft(int, int)
,
turnAheadRight(int, int)
,
turnBackLeft(int, int)
,
turnBackRight(int, int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |