From 25adfc618e77db9a5ee3b98ce0dab0be832efed0 Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Tue, 24 Dec 2024 17:58:20 +0100 Subject: hello kitty base done --- src/main.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src/main.js') 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() +} -- cgit v1.2.3