aboutsummaryrefslogtreecommitdiffstats
path: root/src/enemies/Enemy.ts
blob: cebc1d2ad984b9440d8f7cefbf69288363182240 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import Bullet from "../drawables/Bullet";
import { BULLET_VEL, TOPBAR_HEIGHT } from "../consts";
import Drawable, { Rectangle } from "../Drawable";
import Anime from "../Animation";

export default abstract class Enemy extends Drawable {
  squares: Array<Rectangle> = [new Rectangle(this)]
  points = 50;
  health = 2
  deathAnim!: Anime;

  constructor(x: number, y: number) {
    super(x, y)
  }
  shoot(bullet: Bullet[]): boolean {
    if (this.y2 < TOPBAR_HEIGHT) return false
    bullet.push(new Bullet(this.x + (this.width / 2) - Bullet.width / 2, this.y2, 0, BULLET_VEL / 1.5, false))
    return true
  }
}