-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmadlyseeker.js
65 lines (61 loc) · 1.39 KB
/
madlyseeker.js
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
60
61
62
63
64
65
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
var rx = robot.position.x;
var ry = robot.position.y;
var aH = robot.arenaHeight;
var aW = robot.arenaWidth;
robot.clone()
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if(robot.parentId) {
robot.turn(1);
robot.ahead(1);
robot.rotateCannon(1);
}
else {
robot.turn(-1);
robot.rotateCannon(-1);
robot.ahead(-1);
}
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
if(robot.parentId) {
robot.turn(20);
robot.back(20);
robot.rotateCannon(-20)
}
else {
robot.turn(-20);
robot.rotateCannon(20)
robot.back(100);
}
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
if(robot.parentId) {
robot.turn(20);
robot.back(20);
}
else {
robot.turn(-20);
robot.back(100);
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot, scannedRobot = ev.scannedRobot;
if (robot.id == scannedRobot.parentId || robot.parentId == scannedRobot.id) {
return;
}
if (scannedRobot.parentId && scannedRobot.id == scannedRobot.parentId) {
return;
}
robot.fire();
//
if(robot.parentId)
robot.rotateCannon(-25)
else
robot.rotateCannon(25)
};