diff options
| author | Maksymilian Jopek <maks@jopek.eu> | 2022-06-02 08:54:02 +0200 |
|---|---|---|
| committer | Maksymilian Jopek <maks@jopek.eu> | 2022-06-02 08:54:02 +0200 |
| commit | 6c37585ef4ef2535aff8c45c64850be0a6c26eab (patch) | |
| tree | c53e07505182735fbd23687a0c731d4bb2f10e14 /src/enemies/Straight.ts | |
| parent | 7a494b148dd03d6346a63641fc479015e7450a26 (diff) | |
| download | 1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.tar.gz 1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.tar.zst 1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.zip | |
Death animations
Diffstat (limited to 'src/enemies/Straight.ts')
| -rw-r--r-- | src/enemies/Straight.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/enemies/Straight.ts b/src/enemies/Straight.ts index 895ec01..7bc82f9 100644 --- a/src/enemies/Straight.ts +++ b/src/enemies/Straight.ts @@ -1,6 +1,8 @@ import { canvas } from "../consts"; import { Rectangle } from "../Drawable"; -import { IMGS } from "../Images"; +import Bullet from "../drawables/Bullet"; +import { random } from "../helpers"; +import { getSmallDeathAnim, IMGS } from "../Images"; import Enemy from "./Enemy"; export default class Straight extends Enemy { @@ -36,4 +38,17 @@ export default class Straight extends Enemy { this.squares = [new Rectangle(this, 2, 2, this.width - 2, this.height - 2)] return this.y + this.height < 0 } + + hasShooted = false + shoot(bullets: Bullet[]): boolean { + if (this.hasShooted || this.phase !== 0) return false + if (random(0.008)) { + if (super.shoot(bullets)) + this.hasShooted = true + } + return true; + // (new Bullet(this.width / 2, this.y2, 0, 2, false)) + } + + deathAnim = getSmallDeathAnim(this) } |
