aboutsummaryrefslogtreecommitdiff
path: root/js/mygame.js
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-12-28 19:43:05 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-12-28 19:47:11 +0000
commited0e61af2c9fb7b016cb72a91d207b761859c676 (patch)
tree7a64f254ecb1b921acf561d3aebc47672d0d9714 /js/mygame.js
downloadjs-canvas-2023-ed0e61af2c9fb7b016cb72a91d207b761859c676.tar.gz
js-canvas-2023-ed0e61af2c9fb7b016cb72a91d207b761859c676.zip
Initial import
Diffstat (limited to 'js/mygame.js')
-rw-r--r--js/mygame.js40
1 files changed, 40 insertions, 0 deletions
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();
+ }
+}