blob: 5b4a2faaa78fa7342eaba731d7f06dfc62448984 (
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
|
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);
}
}
}
|