def __init__(self, duck, screen): pygame.sprite.Sprite.__init__(self) self.screen = screen s_width, s_height = settings.getint("Graphics", "width"), settings.getint("Graphics", "height") self.duck = duck self.forward = resource.load_image("duck.png") self.backward = resource.load_image("duck2.png") self.image = self.forward d_width, d_height = self.image.get_size() left = random.randint(0, s_width - d_width - 1) top = random.randint(0, s_height - d_height - 1) self.rect = pygame.rect.Rect(left, top, d_width, d_height) self.speed = duck.productivity * 5 self.set_target() debug("Created duck sprite at %d,%d" % (left, top))
def __init__ (self, xpos, ypos, filename, colorkey=-1): if type(image) is str: image = load_image(image) if colorkey == -1: colorkey = image.get_at((0,0)) if colorkey: image.set_colorkey(colorkey) self.x = xpos self.y = ypos
def __init__(self, pos): pygame.sprite.Sprite.__init__(self) self.images = {} for i in range(8): n = str((i & 4) / 4) n += str((i & 2) / 2) n += str(i & 1) self.images[i] = resource.load_image('player'+n+'.png') self.speed = 100 self.velocity = (0,0) self.state = 0 # Position within the level self.rect = pygame.Rect(pos, self.image.get_size()) # Position of the top left of the image, using floating point self.pos = pos
def __init__(self, image, dimensions, colorkey=-1): if type(image) is str: image = load_image(image) if colorkey == -1: colorkey = image.get_at((0,0)) if colorkey: image.set_colorkey(colorkey) cols, rows = dimensions w = self.width = 1.0 * image.get_width() / cols h = self.height = 1.0 * image.get_height() / rows self._images = [] for y in range(rows): row = [] for x in range(cols): row.append(image.subsurface((x*w,y*h,w,h))) self._images.append(row)
def __init__(self, image, dimensions, colorkey=-1): ###colorkey=-1 is to get rid of background color of spritesheet%%% if type(image) is str: image = load_image(image) if colorkey == -1: colorkey = image.get_at((0,0)) if colorkey: image.set_colorkey(colorkey) cols, rows = dimensions w = self.width = 1.0 * image.get_width() / cols h = self.height = 1.0 * image.get_height() / rows ### tells the program how many sprites are in the spritesheet ### self._images = [] for y in range(rows): row = [] for x in range(cols): row.append(image.subsurface((x*w, y*h, w, h))) self._images.append(row)
def __init__(self, image, dimensions, colorkey=-1): # load the image if type(image) is str: image = load_image(image) if colorkey == -1: colorkey = image.get_at((0, 0)) if colorkey: image.set_colorkey(colorkey) cols, rows = dimensions w = self.width = 1.0 * image.get_width() / cols h = self.height = 1.0 * image.get_height() / rows # build the images self._images = [] for y in range(rows): row = [] for x in range(cols): row.append(image.subsurface((x * w, y * h, w, h))) self._images.append(row)
def __init__(self, texture, dimensions, delay, scale=(1, 1)): self.width, self.height = dimensions self.delay = delay self.timer = 0.0 self.image = resource.load_image(texture) self.rect = self.image.get_rect() nframes_x = int(self.rect.width / self.width) nframes_y = int(self.rect.height / self.height) self.width *= scale[0] self.height *= scale[1] self.image = pygame.transform.scale(self.image, (self.width * nframes_x, self.height * nframes_y)) self.rect = self.image.get_rect() self.frames = [self.image.subsurface(rect) for rect in self.get_frames_rect()] self.using_frames = range(len(self.frames)) self.current_frame = 0 # 1 (right) or -1 (left) self.direction_x = 1 self.direction_y = -1 self.offset = 0
def __init__(self, size): self.bounds = Rect((0,0), size) self.bg_tile = load_image("asphault1")
def __init__(self, size): self.bounds = Rect((0,0), size) self.bg_tile = load_image("grass")
def __init__(self, director, next_screen): object.__init__(self) self.director = director self.next_screen = next_screen self.image = resource.load_image('woman-holding-drawing.png')
def __init__(self, size): self.bounds = Rect((0,0), size) self.bg_tile = load_image("grass") self.coin_sfx = load_sfx("coin")
def __init__(self, director): object.__init__(self) self.director = director self.image = resource.load_image('jacques-fosse.png') pygame.display.flip()
def __init__(self, size): self.bounds = Rect((0, 0), size) self.bg_tile = load_image("grass") self.score_font = pygame.font.Font(None, 48)