aboutsummaryrefslogtreecommitdiffstats
path: root/src/enemies/Straight.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/enemies/Straight.ts')
-rw-r--r--src/enemies/Straight.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/enemies/Straight.ts b/src/enemies/Straight.ts
new file mode 100644
index 0000000..c397332
--- /dev/null
+++ b/src/enemies/Straight.ts
@@ -0,0 +1,17 @@
+import { canvas, PLAYER_VEL } from "../consts";
+import Enemy from "./Enemy";
+
+export default class Straight extends Enemy {
+ width = 20;
+ height = 20;
+ sprite = "blue";
+ vel = PLAYER_VEL * 0.8
+
+ move() {
+ if (this.y + this.height > canvas.height) { this.y = canvas.height - this.height; }
+ else if (this.y === canvas.height - this.height) { this.vel *= -1; this.y += this.vel; }
+ else { this.y += this.vel; }
+
+ return this.y + this.height < 0
+ }
+}