(Underdepths) Prepare for Pass 3
This commit is contained in:
1 parent
b49c285c89
commit
dc8bfd6846
37 files changed
-5590
No files matched your search
@@ -1,35 +0,0 @@
|
||||
"""Base entities: geometric Rect and the generic Entity."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class Rect:
|
||||
x: int
|
||||
y: int
|
||||
w: int
|
||||
h: int
|
||||
|
||||
@property
|
||||
def center(self) -> tuple[int, int]:
|
||||
return (self.x + self.w // 2, self.y + self.h // 2)
|
||||
|
||||
def intersects(self, other: "Rect") -> bool:
|
||||
# True when the two rectangles' interiors overlap (strict inequalities).
|
||||
return (
|
||||
self.x < other.x + other.w
|
||||
and self.x + self.w > other.x
|
||||
and self.y < other.y + other.h
|
||||
and self.y + self.h > other.y
|
||||
)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class Entity:
|
||||
x: int
|
||||
y: int
|
||||
name: str
|
||||
glyph: str
|
||||
color: tuple
|
||||
blocks: bool = True
|
||||
is_alive: bool = True
|
||||
Reference in new issue
Block a user