summaryrefslogtreecommitdiff
path: root/src/scenes.js
blob: c6d175ee285979182ba75c14b55da56fa3d58008 (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
35
36
37
38
import * as PREQUEL from  "./scenes/prequel.js"
import * as HELLO_KITTY from  "./scenes/hello_kitty.js"
import { reload as reloadMain } from "./main.js"
import { Engine } from "./engine.js"

export const SCENES = {
    PREQUEL: "prequel",
    HELLO_KITTY: "hello kitty",
}

export const SCENE = {
    load: loadScene,
    update: null,
    draw: null,
    restart: restartScene,
}

export let currentScene

function loadScene(scene) {
    Engine.frame = 0
    currentScene = scene
    reloadMain()

    if (currentScene == SCENES.PREQUEL) {
        PREQUEL.start()
        SCENE.update = PREQUEL.update
        SCENE.draw = PREQUEL.draw
    }

    if (currentScene == SCENES.HELLO_KITTY) {
        HELLO_KITTY.start()
        SCENE.update = HELLO_KITTY.update
        SCENE.draw = HELLO_KITTY.draw
    }
}

function restartScene() { loadScene (currentScene) }