From a840990bdcabf45fb0d377478ba0ab27222434ae Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Mon, 23 Dec 2024 18:32:29 +0100 Subject: initial commit --- src/engine.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/engine.js (limited to 'src/engine.js') diff --git a/src/engine.js b/src/engine.js new file mode 100644 index 0000000..a7bb8a5 --- /dev/null +++ b/src/engine.js @@ -0,0 +1,34 @@ +import { start, update, draw } from "./main.js" +import { Screen } from "./engine/screen.js" +import { keys, setUpKeyboard } from "./engine/keyboard.js" +import { startClock } from "./engine/clock.js" + +export class Engine { + static frame = 0 + static audio + static screen = new Screen() + static keys = keys + static bgm + + static startEngine() { + setUpKeyboard() + start() + + startClock() + } + + static updateEngine() { + update() + draw() + } + + static playSound(file) { + let audio = new Audio(file) + audio.play() + } + + static playMusic(file) { + this.bgm = new Audio(file) + this.bgm.play() + } +} -- cgit v1.2.3