class Coin(GameEntity): def __init__(self, (x, y), map): GameEntity.__init__(self, (x, y), (30, 30)) self.map = map self.animation = Animation( assets.images.goldpiece.yellow, ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10'))
class MovableEntity(GameEntity): """Abstract MovableEntity class. To create a new MovableEntity, overload the __init__ function and set at least the following attributes on the object: states: A dictionary of possible states. currentState: The current state of the entity. For simple entities, it should suffice to implement only the appropriate states.""" def __init__(self, (x, y), (width, height), map): GameEntity.__init__(self, (x, y), (width, height)) self.map = map self.default_size = (width, height) # Default direction of all entities to right. self.direction = GameEntity.DIRECTION_RIGHT
def render(self, screen, offsets): GameEntity.render(self, screen, self.image, offsets)
class Tile(GameEntity): def __init__(self, name, (x, y)): self.image = assets.images.map.__dict__[name] GameEntity.__init__(self, (x, y), self.image.get_size())
def render(self, screen, offsets): GameEntity.render(self, screen, self.animation.get_image(), offsets)
def render(self, screen, map_offsets): GameEntity.render(self, screen, self.currentState.get_image(), map_offsets)
def act(self, time_passed): GameEntity.act(self, time_passed) if self.location == self.destination: self.destroy() return self.world.test_colision(self)
def __init__(self, world, image, location, destination): GameEntity.__init__(self, world, "bullet", image, location, BULLET_SPEED) self.destination = destination
def __init__(self, world, image, location): GameEntity.__init__(self, world, "cannon", image, location, 0) self.cooldown = MAX_COOLDOWN