-
Notifications
You must be signed in to change notification settings - Fork 0
/
robot.js
51 lines (38 loc) · 1015 Bytes
/
robot.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
'use strict';
var Tracks = require('./tracks'),
Turret = require('./turret'),
Cannon = require('./cannon');
function Robot(board, five) {
this.tracks = new Tracks(board, five);
this.turret = new Turret(board, five);
this.cannon = new Cannon(board, five);
}
Robot.prototype.peaceMode = function () {
this.cannon.deactivate();
};
Robot.prototype.attackMode = function () {
this.cannon.activate();
};
Robot.prototype.fire = function () {
this.cannon.fire();
};
Robot.prototype.aim = function (coords) {
this.turret.moveTo(coords);
};
Robot.prototype.forward = function (speed) {
this.tracks.forward(speed);
};
Robot.prototype.reverse = function (speed) {
this.tracks.reverse(speed);
};
Robot.prototype.left = function (speed) {
this.tracks.left(speed);
};
Robot.prototype.right = function (speed) {
this.tracks.right(speed);
};
Robot.prototype.stop = function () {
this.tracks.stop();
};
Robot.prototype.turret = this.turret;
module.exports = Robot;