mirror of https://github.com/dirtbags/moth.git
New tanks.js to expect what we put out
This commit is contained in:
parent
636d55ef08
commit
a7974758f0
|
@ -43,7 +43,9 @@ function Tank(ctx, width, height, color, sensors) {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
this.turret = turret;
|
this.turret = turret;
|
||||||
this.fire = flags & 1;
|
if (flags & 1) {
|
||||||
|
this.fire = 5;
|
||||||
|
}
|
||||||
this.led = flags & 2;
|
this.led = flags & 2;
|
||||||
this.sensor_state = sensor_state;
|
this.sensor_state = sensor_state;
|
||||||
}
|
}
|
||||||
|
@ -112,8 +114,9 @@ function Tank(ctx, width, height, color, sensors) {
|
||||||
ctx.fillRect(-7, 4, 15, 5);
|
ctx.fillRect(-7, 4, 15, 5);
|
||||||
ctx.rotate(this.turret);
|
ctx.rotate(this.turret);
|
||||||
if (this.fire) {
|
if (this.fire) {
|
||||||
ctx.fillStyle = color;
|
ctx.fillStyle = ("rgba(68,204,68," + this.fire/5 +")");
|
||||||
ctx.fillRect(0, -1, 45, 2);
|
ctx.fillRect(0, -1, 45, 2);
|
||||||
|
this.fire -= 1;
|
||||||
} else {
|
} else {
|
||||||
if (this.led) {
|
if (this.led) {
|
||||||
ctx.fillStyle = "#f00";
|
ctx.fillStyle = "#f00";
|
||||||
|
|
Loading…
Reference in New Issue