From a547b6ede1f4801fdb1f87a536770bfb266aec13 Mon Sep 17 00:00:00 2001 From: retoor Date: Sun, 5 Oct 2025 00:18:06 +0200 Subject: [PATCH] Changed input mode. --- static/js/GameRenderer.js | 16 ++++++++++------ static/js/InputHandler.js | 7 +++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/static/js/GameRenderer.js b/static/js/GameRenderer.js index 5a107b6..1798924 100644 --- a/static/js/GameRenderer.js +++ b/static/js/GameRenderer.js @@ -16,7 +16,7 @@ export class GameRenderer { this.hoveredTile = null; this.cameraPos = { x: 0, y: 50, z: 50 }; - this.cameraZoom = 1; + this.cameraZoom = 1; // Re-introduced for proper orthographic zoom this.TILE_SIZE = 2; this.VIEW_DISTANCE = 50; @@ -242,15 +242,19 @@ export class GameRenderer { } zoomCamera(delta) { - this.cameraZoom = Math.max(0.5, Math.min(2, this.cameraZoom + delta)); - this.updateCameraPosition(); + // Adjust the zoom property. A positive delta (scroll up) increases zoom. + this.cameraZoom += delta; + // Clamp the zoom level to a reasonable range + this.cameraZoom = Math.max(0.5, Math.min(2.5, this.cameraZoom)); + + // Apply the zoom to the camera and update its projection matrix + this.camera.zoom = this.cameraZoom; + this.camera.updateProjectionMatrix(); } updateCameraPosition() { this.camera.position.set( - this.cameraPos.x, - this.cameraPos.y * this.cameraZoom, - this.cameraPos.z * this.cameraZoom + this.cameraPos.x, this.cameraPos.y, this.cameraPos.z ); this.camera.lookAt(this.cameraPos.x, 0, this.cameraPos.z - 50); } diff --git a/static/js/InputHandler.js b/static/js/InputHandler.js index 436eac6..ba22d2a 100644 --- a/static/js/InputHandler.js +++ b/static/js/InputHandler.js @@ -37,8 +37,6 @@ export class InputHandler { if (this.app.isPlacingBuilding && this.app.selectedBuildingType) { // Place building this.app.placeBuilding(tile.x, tile.y); - this.app.isPlacingBuilding = false; - this.app.selectedBuildingType = null; } } } @@ -46,6 +44,11 @@ export class InputHandler { onMouseUp(event) { if (event.button === 2) { // Right mouse button this.isRightMouseDown = false; + + // A right-click should cancel building placement mode + this.app.isPlacingBuilding = false; + this.app.selectedBuildingType = null; + this.canvas.style.cursor = 'default'; // Check if click (not drag)