mirror of
https://github.com/wisplite/a-star-go.git
synced 2026-06-27 15:37:07 -05:00
finally make the zooming proportional so it isn't too fast when zooming out
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"image/color"
|
"image/color"
|
||||||
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -336,8 +337,8 @@ func main() {
|
|||||||
// 1. Where is the mouse in the world BEFORE zooming?
|
// 1. Where is the mouse in the world BEFORE zooming?
|
||||||
worldPosBefore := rl.GetScreenToWorld2D(mousePos, camera)
|
worldPosBefore := rl.GetScreenToWorld2D(mousePos, camera)
|
||||||
|
|
||||||
// 2. Apply the zoom
|
// 2. Apply proportional zoom so wheel steps get smaller as the view zooms out.
|
||||||
camera.Zoom += float32(wheel) * 0.1
|
camera.Zoom *= float32(math.Pow(1.1, float64(wheel)))
|
||||||
if camera.Zoom < 0.01 {
|
if camera.Zoom < 0.01 {
|
||||||
camera.Zoom = 0.01
|
camera.Zoom = 0.01
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user