-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStraferBot.java
More file actions
59 lines (50 loc) · 1.37 KB
/
StraferBot.java
File metadata and controls
59 lines (50 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package Gamma;
import robocode.*;
import java.awt.Color;
// API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
/**
* StraferBot - a robot by (your name here)
*/
public class StraferBot extends Robot
{
/**
* run: StraferBot'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.yellow,Color.black,Color.green); // body,gun,radar
// Robot main loop
while(true) {
// Replace the next 4 lines with any behavior you would like
back(1000);
turnRadarRight(360);
turnLeft(1000);
}
}
/**
* onScannedRobot: What to do when you see another robot
*/
public void onScannedRobot(ScannedRobotEvent e) {
// Replace the next line with any behavior you would like
double bearing;
bearing=e.getBearing();
bearing=e.getVelocity();
}
/**
* 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
turnRight(1000);
}
/**
* 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(1500);
turnLeft(1000);
}
}