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/Strange.ts | |
| parent | 7a494b148dd03d6346a63641fc479015e7450a26 (diff) | |
| download | 1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.tar.gz 1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.tar.zst 1942-6c37585ef4ef2535aff8c45c64850be0a6c26eab.zip | |
Death animations
Diffstat (limited to 'src/enemies/Strange.ts')
| -rw-r--r-- | src/enemies/Strange.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/enemies/Strange.ts b/src/enemies/Strange.ts index 69fd9c0..036409a 100644 --- a/src/enemies/Strange.ts +++ b/src/enemies/Strange.ts @@ -1,5 +1,8 @@ +import { BULLET_VEL, TOPBAR_HEIGHT } from "../consts"; import { Rectangle } from "../Drawable"; -import { IMGS } from "../Images"; +import Bullet from "../drawables/Bullet"; +import { random } from "../helpers"; +import { getBigDeathAnim, IMGS } from "../Images"; import Enemy from "./Enemy"; export default class Strange extends Enemy { @@ -88,5 +91,21 @@ export default class Strange extends Enemy { // this.squares = [new Rectangle(this, 2, 2, this.width - 2, this.height - 2)] return this.isOutsideMap() } + + shoot(bullets: Bullet[]): boolean { + if (this.y2 < TOPBAR_HEIGHT) return false + if (random(0.01)) { + if (random(0.5)) { + bullets.push(new Bullet(this.x + (this.width / 2) - Bullet.width / 2, this.y2, 0, BULLET_VEL, false)) + } else { + if (random(0.5)) bullets.push(new Bullet(this.x + (this.width / 2) - Bullet.width / 2, this.y2, BULLET_VEL - 1, BULLET_VEL - 1, false)) + else bullets.push(new Bullet(this.x + (this.width / 2) - Bullet.width / 2, this.y2, -BULLET_VEL + 1, BULLET_VEL - 1, false)) + } + + } + return true + } + + deathAnim = getBigDeathAnim(this) } |
