aboutsummaryrefslogtreecommitdiffstats
path: root/src/enemies/Straight.ts
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2022-05-24 18:25:43 +0200
committerMaksymilian Jopek <maks@jopek.eu>2022-05-24 18:25:43 +0200
commit2f8b8c87fb2062313afea7b625ccb20d1bea95b9 (patch)
tree973e20986e4b9279b9322a9fd140e6f989eaf492 /src/enemies/Straight.ts
download1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.tar.gz
1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.tar.zst
1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.zip
Initial commit
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
+ }
+}