def update(self, dt, *args, **kwargs): components = self.World.get_components(TransformComponent, RigiBodyComponent) if components is None: return for ent, (trans, rigid) in components: last_vel = Vector2D(rigid.vel.x, rigid.vel.y) rigid.vel += rigid.acc * dt trans.pos += 0.5 * (last_vel + rigid.vel) * dt rigid.acc = Vector2D()
def update(self, *args, **kwargs): components = self.world.get_components(TransformComponent, RenderableComponent) if components is None: return components.sort(key=lambda x: x[1][1].depth) for ent, (trans, rend) in components: sprite = rend.sprite if trans.rot != None: sprite = pg.transform.rotate(sprite.copy(), trans.rot) rend.pos = Vector2D(-0.5 * sprite.get_width(), 0.5)
def update(self, *args, **kwargs): components = self.world.get_component(RigiBodyComponent) if components is None: return for ent, rigid in components: rigid.acc += Vector2D(0, self.force)
def __init__(self, x, y, w, h): self.pos = Vector2D(x, -y) self.w = w self.h = h self.manifolds = []
def __init__(self, x=0, y=0, thresh=0): self.pos = Vector2D(x, -y) self.thresh
def __init__(self, speed_x=0, speed_y=0): self.speed = Vector2D(speed_x, speed_y)
def __init__(self, x, y, rot=None): self.pos = Vector2D(x, y) self.rot = rot
def __init__(self, sprite, x, y, size=None, depth=0): self.sprite = sprite if size is None else pg.transform.scale( sprite, size) self.pos = Vector2D(x, -y) self.depth = depth
def __init__(self, vel_x=0, vel_y=0, acc_x=0, acc_y=0): self.vel = Vector2D(vel_x, vel_y) self.acc = Vector2D(acc_x, acc_y)