feat(sim): tile grid and static entity base
This commit is contained in:
1 parent
990fd2dd0e
commit
bf2ab194e4
2 files changed
+155
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import itertools
|
||||
|
||||
from .geometry import Aabb
|
||||
|
||||
_idCounter = itertools.count(1)
|
||||
|
||||
|
||||
class Actor:
|
||||
def __init__(self, x, y, w, h):
|
||||
self.id = next(_idCounter)
|
||||
self.x = float(x)
|
||||
self.y = float(y)
|
||||
self.w = float(w)
|
||||
self.h = float(h)
|
||||
self.vx = 0.0
|
||||
self.vy = 0.0
|
||||
self.facing = 1
|
||||
self.onGround = False
|
||||
self.onCeiling = False
|
||||
self.onWallLeft = False
|
||||
self.onWallRight = False
|
||||
self.groundPlatform = None
|
||||
self.alive = True
|
||||
self.removed = False
|
||||
|
||||
@property
|
||||
def aabb(self):
|
||||
return Aabb(self.x, self.y, self.w, self.h)
|
||||
|
||||
@property
|
||||
def centerX(self):
|
||||
return self.x + self.w * 0.5
|
||||
|
||||
@property
|
||||
def centerY(self):
|
||||
return self.y + self.h * 0.5
|
||||
|
||||
@property
|
||||
def left(self):
|
||||
return self.x
|
||||
|
||||
@property
|
||||
def right(self):
|
||||
return self.x + self.w
|
||||
|
||||
@property
|
||||
def top(self):
|
||||
return self.y
|
||||
|
||||
@property
|
||||
def bottom(self):
|
||||
return self.y + self.h
|
||||
|
||||
def hurtBox(self):
|
||||
return self.aabb
|
||||
|
||||
def kill(self):
|
||||
self.alive = False
|
||||
Reference in new issue
Block a user