def __init__(self, background_filename, cols, rows): '''Creates a grid, with size set by the background's size.''' picture, rect = load_png(background_filename) self.entities = {} self.col_width = rect.width self.row_height = rect.height self.cols = cols self.rows = rows self.background = pygame.Surface((self.col_width * cols, self.row_height * rows)) for x in xrange(self.cols): for y in xrange(self.rows): rect.topleft = (x*rect.width, y*rect.height) self.background.blit(picture, rect)
def __init__(self, filename): self.image, _ = load_png(filename)