summaryrefslogtreecommitdiff
path: root/src/engine.js
blob: a7bb8a567eebcab82913ce095603815708299971 (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
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()
    }
}