(Underdepths) Prepare for Pass 4
This commit is contained in:
1 parent
eaa13ac86e
commit
f34f4e5014
30 files changed
-4151
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