diff --git a/src/js/game.example.js b/src/js/game.example.js index 2262686..593b606 100644 --- a/src/js/game.example.js +++ b/src/js/game.example.js @@ -25,7 +25,7 @@ let layerHud = new SceneLayer('hud', [ new Sprite('compass-arrow.png', 27, 21), ]); -let layerInstances = new SceneLayer('Instances', [Player.rect]); +let layerInstances = new SceneLayer('Instances', [Player.rect], { debug: true }); // init app let app = new App(document.querySelector('canvas'), 400, 400); diff --git a/src/js/scene.js b/src/js/scene.js index a29c013..187d191 100644 --- a/src/js/scene.js +++ b/src/js/scene.js @@ -21,7 +21,7 @@ export class Scene { } if (typeof item.draw == 'function') { - item.draw(this.#context, true); + item.draw(this.#context, layer.options.debug); } else { console.log(`⛔ Error display '${item.constructor.name}' object.`); } @@ -47,9 +47,21 @@ export class Scene { export class SceneLayer { #objects; - constructor(name, objects = Array()) { + constructor( + name, + objects = Array(), + options = { + debug: false, + } + ) { // TODO: check types this.#objects = Array(); + this.options = options; + + // check options || FIXIT: + if (typeof this.options.debug === 'undefined') { + this.options.debug = false; + } objects.forEach((object) => { this.#objects.push(object);