-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlainRobot.java
51 lines (42 loc) · 1.08 KB
/
PlainRobot.java
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
package test;
public class PlainRobot extends RobotType {
double rAngle, rSpeed; // angle and speed of travel
public PlainRobot() {
}
/** Create plain robot, size ir ay ix,iy, moving at angle ia and speed is
* @param ix
* @param iy
* @param ir
* @param ia
* @param is
*/
public PlainRobot(double ix, double iy, double ir, double ia, double is) {
super(ix, iy, ir);
rAngle = ia;
rSpeed = is;
}
@Override
protected void checkRobot(RobotArena b) {
rAngle = b.CheckBallAngle(x, y, rad, rAngle, RobotID);
}
/**
* adjustRobot
* move robot depending on speed and angle
*/
@Override
protected void adjustRobot() {
double radAngle = rAngle*Math.PI/180; // put angle in radians
x += rSpeed * 0.20* Math.cos(radAngle); // new X position
y += rSpeed * 0.20* Math.sin(radAngle); // new Y position
}
/**
* return string defining robot type
*/
protected String getStrType() {
return "Plain Robot";
}
@Override
protected void drawRobot(RobotInterface ri) {
ri.showRobot(x, y, rad, col);
}
}