class CharacterDrawer(object): def __init__(self, owner, colours): self.owner = owner self.sprite = ComposedSprite(['character', 'weapons'], colours) self.blink_ttl = 0 def draw(self): if self.owner.character.is_invincible(): self.blink_ttl += 1 if self.blink_ttl%6 < 3: return # TODO: resolve animation via equipment classname if self.owner.character.is_on_parachute(): animation = 'parachute' else: if not self.owner.is_on_ground(): if self.owner.velocity[1] > 0: animation = 'jump_up' else: animation = 'jump_down' else: if self.owner.stance == CharacterBody.STANCE_STANDING: if self.owner.velocity[0] != 0: animation = 'running' else: animation = 'standing' elif self.owner.stance == CharacterBody.STANCE_PRONE: animation = 'prone' if animation == 'parachute': animations = [animation] else: animations = [animation, self.owner.equipment.__class__.__name__.lower()] shift = None if animation == 'prone': if animations[1] == 'gun': if self.owner.character.facing_left: shift = [(0, 0), (-4, -3)] else: shift = [(0, 0), (3, -3)] elif animations[1] == 'minigun': if self.owner.character.facing_left: shift = [(0, 0), (-4, -2)] else: shift = [(0, 0), (3, -2)] self.sprite.draw_animation(animations, self.owner.boundingbox, self.owner.character.facing_left, shift)
def __init__(self, owner, colours): self.owner = owner self.sprite = ComposedSprite(['character', 'weapons'], colours) self.blink_ttl = 0