aboutsummaryrefslogtreecommitdiff
path: root/js/mygame.js
blob: bd5b49857d76fb344e5afacb0db37304edfc0018 (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
const floor = Math.floor;
const max = Math.max;
const min = Math.min;

class MyGame extends Game {
    constructor(canvas) {
        super(canvas, 320, 240);

        this.data = {
            sound: "snd/test.ogg",
            world: "json/world.json",
            player: "img/player.png"
        };
        this.dataSize = Object.keys(this.data).length;
    }

    init() {
        /* log the JSON */
        console.log(this.res.world);
    }

    update(dt) {
    }

    draw() {
        /* draw an image */
        this.ctx.drawImage(this.res.player, 0, 0);

        /* play a sound then z is pressed */
        if (this.keys["a"]) {
            this.playSnd(this.res.sound);
        }
    }
}