From ed0e61af2c9fb7b016cb72a91d207b761859c676 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Thu, 28 Dec 2023 19:43:05 +0000 Subject: Initial import --- js/mygame.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 js/mygame.js (limited to 'js/mygame.js') diff --git a/js/mygame.js b/js/mygame.js new file mode 100644 index 0000000..6293150 --- /dev/null +++ b/js/mygame.js @@ -0,0 +1,40 @@ +const floor = Math.floor; +const max = Math.max; +const min = Math.min; + +class MyGame extends Game { + constructor(canvas) { + super(canvas); + this.width = 320; + this.height = 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() { + this.drawStart(); + + /* 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); + } + + this.drawEnd(); + } +} -- cgit v1.2.3