14 Commits

Author SHA1 Message Date
34220818b0 ♻️ revert zoom to center-only, keep middle-click pan 2026-03-20 21:09:13 +00:00
0011bc9877 🐛 fix debug cross: clear+redraw each frame at world-space center, no transforms 2026-03-20 21:06:14 +00:00
6fa3ae4465 🐛 fix debug cross: world-space position + counter-scale, tracks viewport center correctly 2026-03-20 20:57:46 +00:00
6de4c1cbb9 🐛 zoom-to-mouse: track world coords on pointermove, avoid ptr.worldX getter 2026-03-20 20:45:18 +00:00
d354a26a80 🐛 fix zoom-to-mouse: capture worldX/Y before setZoom 2026-03-20 20:39:53 +00:00
fb4abb7256 🐛 zoom-to-mouse: ptr.worldX/Y formula, debug log still active 2026-03-20 20:37:11 +00:00
0e4c7c96ee 🐛 debug: log mouse+center on zoom, draw red cross at viewport center 2026-03-20 20:34:32 +00:00
cccfd9ba73 ♻️ revert zoom to simple center zoom, remove mouse targeting 2026-03-20 20:21:49 +00:00
216c70dbd9 🐛 zoom-to-mouse: use ptr.worldX/Y + set scroll after setZoom 2026-03-20 20:15:13 +00:00
b5130169bd 🐛 fix zoom: center world point under mouse, then zoom to center 2026-03-20 19:39:15 +00:00
f0065a0cda 🐛 fix zoom-to-mouse using getWorldPoint diff instead of manual formula 2026-03-20 19:29:53 +00:00
fa41075c55 📝 update CHANGELOG for Issue #5 mouse handling 2026-03-20 19:19:53 +00:00
715278ae78 zoom to mouse pointer + middle-click pan
- Scroll wheel now zooms toward the mouse cursor instead of screen center
- Middle mouse button held: pan camera by dragging
- Both actions respect current zoom level
2026-03-20 19:19:44 +00:00
2c949cc19e Merge pull request '🐛 Fix resize, Nisse idle bug + rename Villager → Nisse' (#4) from feature/resize-fix into master
Reviewed-on: #4
Reviewed-by: tekki <tekki.mariani@googlemail.com>
2026-03-20 18:58:42 +00:00
2 changed files with 34 additions and 2 deletions

View File

@@ -20,6 +20,8 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Villagers are now called **Nisse** throughout the UI (panel, controls hint, stockpile display, context menu, spawn message) - Villagers are now called **Nisse** throughout the UI (panel, controls hint, stockpile display, context menu, spawn message)
### Added ### Added
- Scroll wheel now zooms toward the mouse cursor position instead of the screen center
- Middle mouse button held: pan the camera by dragging
- Right-click context menu: suppresses browser default, shows Build and Nisse actions in the game world - Right-click context menu: suppresses browser default, shows Build and Nisse actions in the game world
- Initial project setup: Phaser 3 + TypeScript + Vite - Initial project setup: Phaser 3 + TypeScript + Vite
- Core scenes: `BootScene`, `GameScene`, `UIScene` - Core scenes: `BootScene`, `GameScene`, `UIScene`

View File

@@ -23,6 +23,9 @@ export class CameraSystem {
} }
private saveTimer = 0 private saveTimer = 0
private readonly SAVE_TICK = 2000 private readonly SAVE_TICK = 2000
private middlePanActive = false
private lastPanX = 0
private lastPanY = 0
constructor(scene: Phaser.Scene, adapter: LocalAdapter) { constructor(scene: Phaser.Scene, adapter: LocalAdapter) {
this.scene = scene this.scene = scene
@@ -51,8 +54,35 @@ export class CameraSystem {
// Scroll wheel zoom // Scroll wheel zoom
this.scene.input.on('wheel', (_ptr: Phaser.Input.Pointer, _objs: unknown, _dx: number, dy: number) => { this.scene.input.on('wheel', (_ptr: Phaser.Input.Pointer, _objs: unknown, _dx: number, dy: number) => {
const zoom = Phaser.Math.Clamp(cam.zoom - Math.sign(dy) * ZOOM_STEP, MIN_ZOOM, MAX_ZOOM) const newZoom = Phaser.Math.Clamp(cam.zoom - Math.sign(dy) * ZOOM_STEP, MIN_ZOOM, MAX_ZOOM)
cam.setZoom(zoom) cam.setZoom(newZoom)
})
// Middle-click pan: start on button down
this.scene.input.on('pointerdown', (ptr: Phaser.Input.Pointer) => {
if (ptr.middleButtonDown()) {
this.middlePanActive = true
this.lastPanX = ptr.x
this.lastPanY = ptr.y
}
})
// Middle-click pan: move camera while held
this.scene.input.on('pointermove', (ptr: Phaser.Input.Pointer) => {
if (!this.middlePanActive) return
const dx = (ptr.x - this.lastPanX) / cam.zoom
const dy = (ptr.y - this.lastPanY) / cam.zoom
cam.scrollX -= dx
cam.scrollY -= dy
this.lastPanX = ptr.x
this.lastPanY = ptr.y
})
// Middle-click pan: stop on button release
this.scene.input.on('pointerup', (ptr: Phaser.Input.Pointer) => {
if (this.middlePanActive && !ptr.middleButtonDown()) {
this.middlePanActive = false
}
}) })
} }