From 6c37585ef4ef2535aff8c45c64850be0a6c26eab Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Thu, 2 Jun 2022 08:54:02 +0200 Subject: Death animations --- src/enemies/Green1.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/enemies/Green1.ts') diff --git a/src/enemies/Green1.ts b/src/enemies/Green1.ts index 034ab15..2510f97 100644 --- a/src/enemies/Green1.ts +++ b/src/enemies/Green1.ts @@ -1,5 +1,7 @@ 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 Green1 extends Enemy { @@ -53,7 +55,19 @@ export default class Green1 extends Enemy { this.y += dy; this.width = this.sprite.width this.height = this.sprite.height - this.squares = [new Rectangle(this, 2, 2, this.width - 2, this.height - 2)] + this.squares = [new Rectangle(this, 2, 2, this.width - 4, this.height - 4)] return this.isOutsideMap() } + + hasShooted = false; + shoot(bullets: Bullet[]): boolean { + if (this.sprite !== IMGS.greenDown || this.hasShooted) return false; + if (random(0.008)) { + if (super.shoot(bullets)) + this.hasShooted = true + } + return true; + } + + deathAnim = getSmallDeathAnim(this) } -- cgit v1.3.1