action-engine-js 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -334,7 +334,11 @@ canvas {
334
334
 
335
335
  class App {
336
336
  constructor(options = {}) {
337
- this.threelayersystem = new CanvasManager();
337
+ // Check if Game class specifies resolution (allows per-game configuration)
338
+ const width = Game.WIDTH || 800;
339
+ const height = Game.HEIGHT || 600;
340
+
341
+ this.threelayersystem = new CanvasManager(width, height);
338
342
  const canvases = this.threelayersystem.getCanvases();
339
343
  this.audio = new ActionAudioManager();
340
344
  this.input = new ActionInputHandler(this.audio, canvases);
@@ -1,9 +1,8 @@
1
1
  // actionengine/display/canvasmanager.js
2
2
  class CanvasManager {
3
- static get WIDTH() { return 800; }
4
- static get HEIGHT() { return 600; }
5
-
6
- constructor() {
3
+ constructor(width = 800, height = 600) {
4
+ this.width = width;
5
+ this.height = height;
7
6
  this.container = document.getElementById("appContainer");
8
7
 
9
8
  // Create the three canvases with explicit roles
@@ -25,8 +24,8 @@ class CanvasManager {
25
24
  createCanvas(id) {
26
25
  const canvas = document.createElement("canvas");
27
26
  canvas.id = id;
28
- canvas.width = CanvasManager.WIDTH;
29
- canvas.height = CanvasManager.HEIGHT;
27
+ canvas.width = this.width;
28
+ canvas.height = this.height;
30
29
  this.container.appendChild(canvas);
31
30
  return canvas;
32
31
  }
@@ -51,10 +50,10 @@ class CanvasManager {
51
50
  const containerWidth = this.container.clientWidth;
52
51
  const containerHeight = this.container.clientHeight;
53
52
 
54
- const scale = Math.min(containerWidth / CanvasManager.WIDTH, containerHeight / CanvasManager.HEIGHT);
53
+ const scale = Math.min(containerWidth / this.width, containerHeight / this.height);
55
54
 
56
- const scaledWidth = CanvasManager.WIDTH * scale;
57
- const scaledHeight = CanvasManager.HEIGHT * scale;
55
+ const scaledWidth = this.width * scale;
56
+ const scaledHeight = this.height * scale;
58
57
 
59
58
  // Apply scaling to all canvases
60
59
  [this.gameCanvas, this.guiCanvas, this.debugCanvas].forEach((canvas) => {