aboutsummaryrefslogtreecommitdiffstats
path: root/src/enemies/Strange.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/Strange.ts
parentef76266d1a61c02f1721efedc830fab12279d2b9 (diff)
download1942-b4defa324a330217f0139f1240bcf53c0b1f996a.tar.gz
1942-b4defa324a330217f0139f1240bcf53c0b1f996a.tar.zst
1942-b4defa324a330217f0139f1240bcf53c0b1f996a.zip
v1.0.0
Diffstat (limited to 'src/enemies/Strange.ts')
-rw-r--r--src/enemies/Strange.ts30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/enemies/Strange.ts b/src/enemies/Strange.ts
index 036409a..d130326 100644
--- a/src/enemies/Strange.ts
+++ b/src/enemies/Strange.ts
@@ -12,9 +12,13 @@ export default class Strange extends Enemy {
vel = 1
phase = 0;
spriteCounter = 0;
+ si = 0;
+ changeSprite = true;
spriteNum = 1;
i = 0;
squares: Rectangle[] = [new Rectangle(this, 2, 2, this.width - 2, this.height - 2)]
+ health = 30
+ points = 2100
move() {
let dx = 0, dy = 0;
@@ -82,10 +86,26 @@ export default class Strange extends Enemy {
break;
}
+ if (this.spriteCounter++ === 3) { this.spriteNum ^= 1; this.spriteCounter = 0; }
+ let strSprite = "bigStrangeUp" + this.spriteNum;
+ if (this.health < 30 - 20) {
+ if (this.si++ > 3) { this.changeSprite = !this.changeSprite; this.si = 0; }
+ }
+ else if (this.health < 30 - 10) {
+ if (this.si++ > 8) { this.changeSprite = !this.changeSprite; this.si = 0; }
+ }
+ else if (this.health < 30) {
+ if (this.si++ > 30) { this.changeSprite = !this.changeSprite; this.si = 0; }
+ }
+ if (this.changeSprite === true && this.health < 30)
+ //@ts-expect-error
+ this.sprite = IMGS[strSprite + "Red"]
+ else
+ //@ts-expect-error
+ this.sprite = IMGS[strSprite]
+
this.x += dx;
this.y += dy;
- //@ts-expect-error
- if (this.spriteCounter++ === 3) { this.spriteNum ^= 1; this.sprite = IMGS["bigStrangeUp" + this.spriteNum]; this.spriteCounter = 0; }
// this.width = this.sprite.width
// this.height = this.sprite.height
// this.squares = [new Rectangle(this, 2, 2, this.width - 2, this.height - 2)]
@@ -96,10 +116,10 @@ export default class Strange extends Enemy {
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))
+ bullets.push(new Bullet(this.x + (this.width / 2) - Bullet.width / 2, this.y2, 0, BULLET_VEL / 2, 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))
+ if (random(0.5)) bullets.push(new Bullet(this.x + (this.width / 2) - Bullet.width / 2, this.y2, BULLET_VEL / 2, BULLET_VEL / 2, false))
+ else bullets.push(new Bullet(this.x + (this.width / 2) - Bullet.width / 2, this.y2, -BULLET_VEL / 2, BULLET_VEL / 2, false))
}
}