(Underdepths) Prepare for Pass 4
This commit is contained in:
33 files changed
+123
-4173
No files matched your search
@@ -1,18 +0,0 @@
|
||||
"""Camera: viewport offset that follows the player, clamped to the map."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class Camera:
|
||||
x: int = 0
|
||||
y: int = 0
|
||||
|
||||
def follow(self, target_x: int, target_y: int, view_w: int, view_h: int,
|
||||
map_w: int, map_h: int) -> None:
|
||||
self.x = target_x - view_w // 2
|
||||
self.y = target_y - view_h // 2
|
||||
self.x = max(0, min(self.x, max(0, map_w - view_w)))
|
||||
self.y = max(0, min(self.y, max(0, map_h - view_h)))
|
||||
Reference in new issue
Block a user