Changed input mode.
This commit is contained in:
parent
084fce0a9b
commit
a547b6ede1
@ -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);
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user