diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-23 18:32:29 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-23 18:32:29 +0100 |
commit | a840990bdcabf45fb0d377478ba0ab27222434ae (patch) | |
tree | 030a6c3a6befce284733f5643d3972e3a1504bb2 /src/main.js |
initial commit
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() +} |