def __init__(self, color, width, height, xoffset=0, yoffset=0): Sprite.__init__(self, xoffset=xoffset, yoffset=yoffset) self.width = width self.height = height self.color = color self.hitbox = hitboxes.Box(self.width, self.height)
def __init__(self, path, dimensions=None, transparent_bkg=False, xoffset=0, yoffset=0): Sprite.__init__(self, xoffset=xoffset, yoffset=yoffset) self.transparent_bkg = transparent_bkg if isinstance(path, pygame.Surface): self.path = None self.surf = path else: self.path = path self.surf = pygame.image.load(self.path) if self.transparent_bkg: color = self.surf.get_at((0, 0)) self.surf.set_colorkey(color) if dimensions: self.surf = pygame.transform.scale(self.surf, dimensions) self.size = self.surf.get_rect().size self.orig_surf = tools.clone(self.surf) self.hitbox = hitboxes.Box(*self.size)
def perma_scale(self, scale): size = map(lambda x: int(x * scale), self.size) self.surf = pygame.transform.scale(self.surf, size) self.size = self.surf.get_rect().size self.hitbox = hitboxes.Box(*self.size) self.orig_surf = self.surf return self
def __init__(self, text, font, xoffset=0, yoffset=0): Sprite.__init__(self, xoffset=xoffset, yoffset=yoffset) self.text = text self.font = font self.surf = self.font.get_surf(self.text) self.size = self.font.size(self.text) self.hitbox = hitboxes.Box(*self.size)
def __init__(self, color, width, height, xoffset=0, yoffset=0, linewidth=1): Sprite.__init__(self, xoffset=xoffset, yoffset=yoffset) self.width = width self.height = height self.color = color self.lines = [(0, 0), (width, 0), (width, height), (0, height)] self.linewidth = linewidth self.hitbox = hitboxes.Box(self.width, self.height)
def __init__(self, path, dimensions=None, xoffset=0, yoffset=0): Sprite.__init__(self, xoffset=xoffset, yoffset=yoffset) if isinstance(path, pygame.Surface): self.path = None self.surf = path else: self.path = path self.surf = pygame.image.load(self.path) if dimensions: self.surf = pygame.transform.scale(self.surf, dimensions) self.size = self.surf.get_rect().size self.hitbox = hitboxes.Box(*self.size)