fix: const redeclaration bug + bare ctx references

- Remove duplicate const TILE_HEIGHT/TILE_WIDTH in player.js and game.js
- Use var TILE_HEIGHT_PLAYER in player.js to avoid collision
- Fix bare ctx → this.ctx in monster render
- Fix ctx = this.ctx → const ctx = this.ctx in NPC render

This was causing a SyntaxError that prevented the entire game from loading.
This commit is contained in:
arch_agent
2026-07-17 20:42:39 +02:00
parent face8023a4
commit 3890395885
2 changed files with 15 additions and 19 deletions
+4 -7
View File
@@ -1,8 +1,5 @@
// game.js — Main Game Loop
const TILE_WIDTH = 64;
const TILE_HEIGHT = 32;
class Game {
constructor() {
this.canvas = document.getElementById('game-canvas');
@@ -336,7 +333,7 @@ class Game {
class_master: '#8a4a8a',
innkeeper: '#8a8a4a'
};
ctx = this.ctx;
const ctx = this.ctx;
ctx.fillStyle = colors[npc.type] || '#666';
ctx.fillRect(drawX - 5, drawY + TILE_HEIGHT/2 - 15, 10, 12);
ctx.fillStyle = '#e0b890';
@@ -374,9 +371,9 @@ class Game {
this.ctx.fillStyle = '#666';
this.ctx.fillRect(drawX - 6, drawY + TILE_HEIGHT/2 - 10, 12, 8);
this.ctx.fillStyle = '#555';
ctx.beginPath();
ctx.arc(drawX, drawY + TILE_HEIGHT/2 - 12, 5, 0, Math.PI * 2);
ctx.fill();
this.ctx.beginPath();
this.ctx.arc(drawX, drawY + TILE_HEIGHT/2 - 12, 5, 0, Math.PI * 2);
this.ctx.fill();
// Eyes (red)
this.ctx.fillStyle = '#ff3333';