Difference between revisions of "User talk:Tmservo"
Jump to navigation
Jump to search
(Blanked the page) |
|||
| Line 1: | Line 1: | ||
| + | <syntaxhighlight> | ||
| + | package josewong; | ||
| + | import robocode.*; | ||
| + | //import java.awt.Color; | ||
| + | // API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html | ||
| + | |||
| + | /** | ||
| + | * KlaraLibriYVY - a robot by (your name here) | ||
| + | */ | ||
| + | public class KlaraLibriYVY extends Robot | ||
| + | { | ||
| + | /** | ||
| + | * run: KlaraLibriYVY's default behavior | ||
| + | */ | ||
| + | public void run() { | ||
| + | // Initialization of the robot should be put here | ||
| + | |||
| + | // After trying out your robot, try uncommenting the import at the top, | ||
| + | // and the next line: | ||
| + | |||
| + | // setColors(Color.red,Color.blue,Color.green); // body,gun,radar | ||
| + | |||
| + | // Robot main loop | ||
| + | while(true) { | ||
| + | // Replace the next 4 lines with any behavior you would like | ||
| + | ahead(100); | ||
| + | turnGunRight(360); | ||
| + | back(100); | ||
| + | turnGunLeft(360); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * onScannedRobot: What to do when you see another robot | ||
| + | */ | ||
| + | public void onScannedRobot(ScannedRobotEvent e) { | ||
| + | // Replace the next line with any behavior you would like | ||
| + | fire(1); | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * onHitByBullet: What to do when you're hit by a bullet | ||
| + | */ | ||
| + | public void onHitByBullet(HitByBulletEvent e) { | ||
| + | // Replace the next line with any behavior you would like | ||
| + | back(10); | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * onHitWall: What to do when you hit a wall | ||
| + | */ | ||
| + | public void onHitWall(HitWallEvent e) { | ||
| + | // Replace the next line with any behavior you would like | ||
| + | back(20); | ||
| + | } | ||
| + | } | ||
| + | </syntaxhighlight> | ||
Revision as of 00:22, 16 December 2013
package josewong;
import robocode.*;
//import java.awt.Color;
// API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
/**
* KlaraLibriYVY - a robot by (your name here)
*/
public class KlaraLibriYVY extends Robot
{
/**
* run: KlaraLibriYVY's default behavior
*/
public void run() {
// Initialization of the robot should be put here
// After trying out your robot, try uncommenting the import at the top,
// and the next line:
// setColors(Color.red,Color.blue,Color.green); // body,gun,radar
// Robot main loop
while(true) {
// Replace the next 4 lines with any behavior you would like
ahead(100);
turnGunRight(360);
back(100);
turnGunLeft(360);
}
}
/**
* onScannedRobot: What to do when you see another robot
*/
public void onScannedRobot(ScannedRobotEvent e) {
// Replace the next line with any behavior you would like
fire(1);
}
/**
* onHitByBullet: What to do when you're hit by a bullet
*/
public void onHitByBullet(HitByBulletEvent e) {
// Replace the next line with any behavior you would like
back(10);
}
/**
* onHitWall: What to do when you hit a wall
*/
public void onHitWall(HitWallEvent e) {
// Replace the next line with any behavior you would like
back(20);
}
}