summaryrefslogtreecommitdiff
path: root/src/entities/boshy.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities/boshy.js')
-rw-r--r--src/entities/boshy.js51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/entities/boshy.js b/src/entities/boshy.js
index ea6068d..9a2b589 100644
--- a/src/entities/boshy.js
+++ b/src/entities/boshy.js
@@ -3,11 +3,17 @@ import { Vector } from "../engine/vector.js"
import { Engine } from "../engine.js"
import { BoshyBullet } from "./boshybullet.js"
import { Entity } from "./entity.js"
+import { SCENES, currentScene } from "../scenes.js"
+import { boshyDied } from "../main.js"
+import { Blood } from "./boshyblood.js"
export class Boshy extends Entity {
reloadTime = 6
lastShot = 0
- speed = 5
+ speed = 4
+
+ canmove = true
+ dead = false
constructor() {
super({
@@ -16,10 +22,19 @@ export class Boshy extends Entity {
sprite: BOSHY.NORMAL,
})
- Engine.playSound(BOSHY.SOUNDS.INTRO)
+ switch (currentScene) {
+ case SCENES.PREQUEL:
+ Engine.radio.playSound(BOSHY.SOUNDS.INTRO2)
+ break;
+
+ case SCENES.HELLO_KITTY:
+ Engine.radio.playSound(BOSHY.SOUNDS.INTRO)
+ break;
+ }
}
update() {
+ if (!this.canmove) return
let keys = Engine.keys
let viewport = Engine.screen.viewport
@@ -60,6 +75,36 @@ export class Boshy extends Entity {
new BoshyBullet(bullet_a_position)
new BoshyBullet(bullet_b_position)
- Engine.playSound(BOSHY.SOUNDS.SHOOT)
+ // new BoshyBullet(this.position.clone())
+ Engine.radio.playSound(BOSHY.SOUNDS.SHOOT)
+ }
+
+ die() {
+ if (this.dead) return
+ this.dead = true
+ this.playDeathSounds()
+ this.spawnBlood()
+
+ this.position.x = 0
+ this.position.y = Engine.screen.viewport.y
+ this.remove()
+ boshyDied()
+ }
+
+ playDeathSounds() {
+ Engine.radio.playSound(BOSHY.SOUNDS.DEAD)
+
+ switch (Engine.random(1, 4)) {
+ case 1: Engine.radio.playSound(BOSHY.SOUNDS.DEADQUOTE1); break;
+ case 2: Engine.radio.playSound(BOSHY.SOUNDS.DEADQUOTE2); break;
+ case 3: Engine.radio.playSound(BOSHY.SOUNDS.DEADQUOTE3); break;
+ case 4: Engine.radio.playSound(BOSHY.SOUNDS.DEADQUOTE4); break;
+ }
+ }
+
+ spawnBlood() {
+ for (let i = 0; i<20; i++) {
+ new Blood(this.position.clone().floor())
+ }
}
}