Hi all,
Apologies if this has been discussed before; I did a quick search across Google and this forum but didn’t find much. Please point me in the right direction if this is a duplicate question
So what I’m trying to do is create a clone of the classic Super Mario Bros. game on the Nintendo Entertainment System, using p5.play.js.
In the interest of adhering to proper OO design principles, I’d like to have the following ES6 class as the main “controller” of my game:
class SuperMarioJS {
constructor() {
this.currentLevel = new Level('world 1.1');
this.mario = new Mario(); // 'Mario' class extends p5.play.Sprite
// other initialisation code...
}
static get GRAVITY() { return 1.0; }
// other global constants...
setup() {
createCanvas(this.currentLevel.width, windowHeight);
// other setup code...
}
draw() {
this.mario.move();
drawSprites();
}
}
And then the only global code attached to the window
object would be:
var gameController = new SuperMarioJS();
function setup() { gameController.setup(); }
function draw() { gameController.draw(); }
But this doesn’t work. I don’t get any errors or anything logged to the browser console, but I simply end up with a black screen and nothing else!
So what would be the best way to approach this? MTIA!