(Underdepth) Prepare for Pass 5
This commit is contained in:
1 parent
6147ab3121
commit
05e340dec2
29 files changed
-4888
No files matched your search
@@ -1,27 +0,0 @@
|
||||
"""Viewport camera that eases toward the player each frame (plan.md Juice)."""
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
|
||||
|
||||
class Camera:
|
||||
"""Pixel-space camera top-left. Eases toward its target; can snap."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.x: float = 0.0
|
||||
self.y: float = 0.0
|
||||
self._tx: float = 0.0
|
||||
self._ty: float = 0.0
|
||||
|
||||
def set_target(self, px: float, py: float) -> None:
|
||||
self._tx = px
|
||||
self._ty = py
|
||||
|
||||
def snap(self, px: float, py: float) -> None:
|
||||
self.x = self._tx = px
|
||||
self.y = self._ty = py
|
||||
|
||||
def update(self, dt: float, ease: float = 7.0) -> None:
|
||||
k = 1.0 - math.exp(-ease * dt)
|
||||
self.x += (self._tx - self.x) * k
|
||||
self.y += (self._ty - self.y) * k
|
||||
Reference in new issue
Block a user