aboutsummaryrefslogtreecommitdiffstats
path: root/src/enemies/White.ts
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2022-06-02 23:13:07 +0200
committerMaksymilian Jopek <maks@jopek.eu>2022-06-02 23:16:33 +0200
commitb4defa324a330217f0139f1240bcf53c0b1f996a (patch)
treedeabb94fd351b10d3d6b38d967424149536b3927 /src/enemies/White.ts
parentef76266d1a61c02f1721efedc830fab12279d2b9 (diff)
download1942-b4defa324a330217f0139f1240bcf53c0b1f996a.tar.gz
1942-b4defa324a330217f0139f1240bcf53c0b1f996a.tar.zst
1942-b4defa324a330217f0139f1240bcf53c0b1f996a.zip
v1.0.0
Diffstat (limited to 'src/enemies/White.ts')
-rw-r--r--src/enemies/White.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/enemies/White.ts b/src/enemies/White.ts
index e5b22ae..768300d 100644
--- a/src/enemies/White.ts
+++ b/src/enemies/White.ts
@@ -1,4 +1,6 @@
import { Rectangle } from "../Drawable";
+import Bullet from "../drawables/Bullet";
+import { random } from "../helpers";
import { getSmallDeathAnim, IMGS } from "../Images";
import Enemy from "./Enemy";
@@ -15,6 +17,8 @@ export default class White extends Enemy {
constructor(x: number, y: number, public left: boolean) {
super(x, y)
+ this.height = IMGS.whiteDown.height;
+ this._y = y - this.height
}
move() {
@@ -65,7 +69,15 @@ export default class White extends Enemy {
return this.isOutsideMap()
}
- shoot(): boolean { return false }
+ hasShooted = false;
+ shoot(bullets: Bullet[]): boolean {
+ if (this.sprite !== IMGS.whiteDown || this.hasShooted) return false;
+ if (random(0.008)) {
+ if (super.shoot(bullets))
+ this.hasShooted = true
+ }
+ return true;
+ }
deathAnim = getSmallDeathAnim(this)
}