summaryrefslogtreecommitdiff
path: root/src/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.js')
-rw-r--r--src/main.js34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/main.js b/src/main.js
index 6822351..922ad52 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,38 +1,48 @@
///////////////////// IMPORTS //////////////////////
import { Boshy } from "./entities/boshy.js"
import { SCENE, SCENES } from "./scenes.js"
+import { HPBar } from "./entities/hp_bar.js"
+import { GameOver } from "./entities/game_over.js"
+import { Engine } from "./engine.js"
+import { MUSIC } from "./assets.js"
///////////////////// GLOBALS //////////////////////
export let boshy
-export const bullets = {
+export const entities = {
list: [],
- remove: instance => { bullets.list = bullets.list.filter(b => b != instance) },
- clear: _ => { bullets.list.forEach(b => b.remove()) }
+ remove: instance => { entities.list = entities.list.filter(b => b != instance) },
+ clear: _ => { entities.list.forEach(b => b.remove()) }
}
+export let enemy
///////////////////// GAME LOGIC //////////////////////
export function start() {
console.log("game start")
- changeScene(SCENES.PREQUEL)
+ SCENE.load(SCENES.PREQUEL)
}
export function update() {
- boshy.update()
- bullets.list.forEach((bullet) => bullet.update())
+ entities.list.forEach((entity) => entity.update())
SCENE.update()
}
export function draw() {
- boshy.draw()
- bullets.list.forEach((bullet) => bullet.draw())
+ entities.list.forEach((entity) => entity.draw())
SCENE.draw()
}
-///////////////////// SCENE METHODS //////////////////////
-export function changeScene(scene) {
- SCENE.load(scene)
- bullets.clear()
+///////////////////// METHODS //////////////////////
+export function reload() {
+ if (boshy != undefined) boshy.remove()
+ entities.clear()
+ enemy = undefined
boshy = new Boshy()
}
+
+export function setEnemy(e) { enemy = e; new HPBar() }
+export function boshyDied() {
+ Engine.radio.playMusic(MUSIC.LOLUDIED)
+ new GameOver()
+}