| 23 | } |
| 24 | |
| 25 | func (camera *Camera) Update() { |
| 26 | |
| 27 | softness := camera.Softness |
| 28 | |
| 29 | if !globals.Settings.Get(SettingsSmoothMovement).AsBool() { |
| 30 | softness = 1 |
| 31 | } |
| 32 | |
| 33 | camera.Zoom += (camera.TargetZoom - camera.Zoom) * softness |
| 34 | |
| 35 | if math.Abs(float64(camera.TargetZoom-camera.Zoom)) < 0.01 { |
| 36 | camera.Zoom = camera.TargetZoom |
| 37 | } |
| 38 | |
| 39 | globals.Renderer.SetScale(camera.Zoom, camera.Zoom) |
| 40 | |
| 41 | camera.Position = camera.Position.Add(camera.TargetPosition.Sub(camera.Position).Mult(softness)) |
| 42 | |
| 43 | } |
| 44 | |
| 45 | func (camera *Camera) JumpTo(pos Vector, zoom float32) { |
| 46 | camera.TargetPosition = pos |