Spaces:
Running
Running
Create tower.js
Browse files
tower.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class Tower {
|
| 2 |
+
constructor(x, y) {
|
| 3 |
+
this.x = x;
|
| 4 |
+
this.y = y;
|
| 5 |
+
this.radius = 50;
|
| 6 |
+
this.color = 'blue';
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
update() {
|
| 10 |
+
this.draw();
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
draw() {
|
| 14 |
+
ctx.beginPath();
|
| 15 |
+
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
|
| 16 |
+
ctx.fillStyle = this.color;
|
| 17 |
+
ctx.fill();
|
| 18 |
+
}
|
| 19 |
+
}
|