From 2f8b8c87fb2062313afea7b625ccb20d1bea95b9 Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Tue, 24 May 2022 18:25:43 +0200 Subject: Initial commit --- src/enemies/Straight.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/enemies/Straight.ts (limited to 'src/enemies/Straight.ts') 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 + } +} -- cgit v1.3.1