Chronos234 commited on
Commit
3dfec0b
·
verified ·
1 Parent(s): 745c1ca

Create enemy.js

Browse files
Files changed (1) hide show
  1. enemy.js +24 -0
enemy.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class Enemy {
2
+ constructor(x, y) {
3
+ this.x = x;
4
+ this.y = y;
5
+ this.size = 30;
6
+ this.speed = 1;
7
+ }
8
+
9
+ update() {
10
+ this.move();
11
+ this.draw();
12
+ }
13
+
14
+ move() {
15
+ this.y += this.speed;
16
+ }
17
+
18
+ draw() {
19
+ ctx.beginPath();
20
+ ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
21
+ ctx.fillStyle = 'red';
22
+ ctx.fill();
23
+ }
24
+ }