zoom to mouse instead of screen center

This commit is contained in:
Zutatensuppe 2021-04-15 10:01:27 +02:00
parent 43db4daa11
commit 38bef17010
2 changed files with 22 additions and 15 deletions

View file

@ -564,14 +564,14 @@ async function main() {
} else if (type === Protocol.INPUT_EV_MOUSE_UP) {
_last_mouse_down = null
} else if (type === Protocol.INPUT_EV_ZOOM_IN) {
if (viewport.zoomIn()) {
const pos = { x: evt[1], y: evt[2] }
const pos = { x: evt[1], y: evt[2] }
if (viewport.zoomIn(viewport.worldToViewport(pos))) {
RERENDER = true
Game.changePlayer(gameId, CLIENT_ID, pos)
}
} else if (type === Protocol.INPUT_EV_ZOOM_OUT) {
if (viewport.zoomOut()) {
const pos = { x: evt[1], y: evt[2] }
const pos = { x: evt[1], y: evt[2] }
if (viewport.zoomOut(viewport.worldToViewport(pos))) {
RERENDER = true
Game.changePlayer(gameId, CLIENT_ID, pos)
}
@ -607,10 +607,12 @@ async function main() {
} else if (type === Protocol.INPUT_EV_MOUSE_UP) {
_last_mouse_down = null
} else if (type === Protocol.INPUT_EV_ZOOM_IN) {
viewport.zoomIn()
const pos = { x: evt[1], y: evt[2] }
viewport.zoomIn(viewport.worldToViewport(pos))
RERENDER = true
} else if (type === Protocol.INPUT_EV_ZOOM_OUT) {
viewport.zoomOut()
const pos = { x: evt[1], y: evt[2] }
viewport.zoomOut(viewport.worldToViewport(pos))
RERENDER = true
}
}