blob: 922ad525339a7120dbd818d048cd7d42ee82f41e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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 entities = {
list: [],
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")
SCENE.load(SCENES.PREQUEL)
}
export function update() {
entities.list.forEach((entity) => entity.update())
SCENE.update()
}
export function draw() {
entities.list.forEach((entity) => entity.draw())
SCENE.draw()
}
///////////////////// 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()
}
|