diff options
Diffstat (limited to 'src/main.js')
-rw-r--r-- | src/main.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..6822351 --- /dev/null +++ b/src/main.js @@ -0,0 +1,38 @@ +///////////////////// IMPORTS ////////////////////// +import { Boshy } from "./entities/boshy.js" +import { SCENE, SCENES } from "./scenes.js" + + +///////////////////// GLOBALS ////////////////////// +export let boshy +export const bullets = { + list: [], + remove: instance => { bullets.list = bullets.list.filter(b => b != instance) }, + clear: _ => { bullets.list.forEach(b => b.remove()) } +} + +///////////////////// GAME LOGIC ////////////////////// +export function start() { + console.log("game start") + changeScene(SCENES.PREQUEL) +} + +export function update() { + boshy.update() + bullets.list.forEach((bullet) => bullet.update()) + SCENE.update() +} + +export function draw() { + boshy.draw() + bullets.list.forEach((bullet) => bullet.draw()) + SCENE.draw() +} + + +///////////////////// SCENE METHODS ////////////////////// +export function changeScene(scene) { + SCENE.load(scene) + bullets.clear() + boshy = new Boshy() +} |