def update(self, maze, screen): """Update position based on movement flags""" if gf.stop_ball(self, maze) is False and pygame.time.get_ticks( ) - self.timer >= self.tick_speed: self.timer = pygame.time.get_ticks() if self.move == "l": self.image.rect.x -= self.speed file = "p_left_" + str(math.floor(self.index)) elif self.move == "r": self.image.rect.x += self.speed file = "p_right_" + str(math.floor(self.index)) elif self.move == "d": self.image.rect.y += self.speed file = "p_down_" + str(math.floor(self.index)) elif self.move == "u": self.image.rect.y -= self.speed file = "p_up_" + str(math.floor(self.index)) else: file = "p_up_1" self.image = ImageRect(screen, file, PM.PAC_SIZE, PM.PAC_SIZE) self.image.rect = self.rect if self.index >= 4: self.index = 1 else: self.index += .3 """For testing"""
def __init__(self, screen, maze): super(PM, self).__init__() self.screen = screen.get_rect() self.image = ImageRect(screen, "p_left_2", PM.PAC_SIZE, PM.PAC_SIZE) self.rect = self.image.rect self.rect.x = self.screen.centerx - 10 self.rect.y = self.screen.centery + 110 self.maze = maze # Setting movement flags - Pacman starts moving left as game starts self.direction = "l" self.move = "l" # Speed self.speed = 5 self.tick_speed = 10 self.timer = pygame.time.get_ticks() # Index for images self.index = 1 self.dead_index = 1 self.sound_index = 1 # Set movement flags as false self.direction_l = False self.direction_r = False self.direction_u = False self.direction_d = False # For the scores self.lives = 3 self.score = 0
def __init__(self, screen, mazefile): self.screen = screen self.filename = mazefile # Load line image and get its rect and change the size to 20 x 20 # self.image = pygame.image.load('images/square.png') # self.image = pygame.transform.scale(self.image, (20, 20)) # self.rect = self.image.get_rect() # self.screen_rect = screen.get_rect() with open('maze.txt', 'r') as f: self.rows = f.readlines() # for bricks self.bricks = [] self.brick = ImageRect(screen, "square", Maze.BRICK_SIZE, Maze.BRICK_SIZE) # self.brick_x = brick_y = Maze.BRICK_SIZE # for balls self.balls = [] self.ball = ImageRect(screen, "ball", 10, 10) # for the line (gate) self.lines = [] self.line = ImageRect(screen, "line", 10, 10) # for power pill self.pills = [] self.pill = ImageRect(screen, "pill", 10, 10) self.build()
def __init__(self, screen, row, col, maze): super(PacMan, self).__init__() self.screen = screen self.s_rect = screen.get_rect() self.im = ImageRect(screen, "pac_man_1", 18, 18) self.im.rect.centerx = col * 10 + 5 self.im.rect.centery = row * 10 + 5 self.maze = maze self.rect = self.im.rect self.moving_up = False self.moving_down = False self.moving_right = False self.moving_left = False self.speed = 10 self.state = 1 self.death_state = 1 self.dir = "" self.speed_timer = pygame.time.get_ticks() self.row = row self.col = col self.walls = [ 'T', 'B', 'R', 'L', 'G', 'M', 'N', 'O', 'Y', 'Z', 'W', 'X', 'S' ] self.dead = False self.sound_timer = pygame.time.get_ticks() self.finished = False
def __init__(self, screen, x, y, direction, maze, p_type=P_TYPE_1): self.screen = screen self.maze = maze self.direction = direction self.p_type = p_type if p_type == Portal.P_TYPE_1: self.images = ImageRect('blue-portal-bg.png', sheet=True, pos_offsets=[(0, 0, 32, 32), (32, 0, 32, 32), (64, 0, 32, 32), (0, 32, 32, 32), (32, 32, 32, 32), (64, 32, 32, 32), (0, 64, 32, 32)], resize=(self.maze.block_size, self.maze.block_size), animation_delay=250) image, _ = self.images.get_image() else: self.images = ImageRect('orange-portal-bg.png', sheet=True, pos_offsets=[(0, 0, 32, 32), (32, 0, 32, 32), (64, 0, 32, 32), (0, 32, 32, 32), (32, 32, 32, 32), (64, 32, 32, 32), (0, 64, 32, 32)], resize=(self.maze.block_size, self.maze.block_size), animation_delay=250) image, _ = self.images.get_image() super().__init__(x, y, maze.block_size, maze.block_size, image)
def __init__(self, screen, sprite_sheet, sheet_offsets, pos=(0, 0), resize=None, detail=None, frame_delay=None, flip=False): super().__init__() self.screen = screen if not resize: resize = (self.screen.get_height() // 10, self.screen.get_height() // 10) self.image_manager = ImageRect(sprite_sheet, sheet=True, pos_offsets=sheet_offsets, resize=resize, animation_delay=frame_delay) if flip: self.image_manager.flip() self.image, self.rect = self.image_manager.get_image() if detail: self.detail_piece = ImageRect(detail, sheet=True, pos_offsets=sheet_offsets, resize=resize).all_images()[0] if flip: self.image_manager.flip() self.image.blit(self.detail_piece, (0, 0)) else: self.detail_piece = None self.rect.centerx, self.rect.centery = pos
class Cherry(Sprite): CHERRY_SIZE = 30 def __init__(self, screen): super(Cherry, self).__init__() self.screen = screen.get_rect() self.image = ImageRect(screen, "cherry", Cherry.CHERRY_SIZE, Cherry.CHERRY_SIZE) self.rect = self.image.rect # Starts the cherry at this location self.rect.x = 300 self.rect.y = 390 def blitme(self): self.image.blitme() def update(self, pm): self.collide(pm) def collide(self, pm): """Collision for the dead ghost""" if pygame.sprite.collide_rect(self, pm): self.rect.x = 800 self.rect.y = 800 pm.score += 200 eat = pygame.mixer.Sound('sounds/eatfruit.wav') eat.play()
def __init__(self, screen, mazefile, brickfile, dotfile, powerpill): self.screen = screen self.filename = mazefile with open(self.filename, 'r') as f: self.rows = f.readlines() self.bricks = [] self.dots = [] # self.dots = Group() self.pills = [] sz = Maze.BRICK_SIZE sz1 = Maze.DOT_SIZE sz2 = Maze.PILL_SIZE self.brick = ImageRect(screen, brickfile, sz, sz) self.dot = ImageRect(screen, dotfile, sz1, sz1) # self.dots.add(ImageRect(screen, dotfile, sz1, sz1)) self.nodes = [] self.pill = ImageRect(screen, powerpill, sz2, sz2) self.deltax = self.deltay = Maze.BRICK_SIZE self.build()
def __init__(self, screen): super(Cherry, self).__init__() self.screen = screen.get_rect() self.image = ImageRect(screen, "cherry", Cherry.CHERRY_SIZE, Cherry.CHERRY_SIZE) self.rect = self.image.rect # Starts the cherry at this location self.rect.x = 300 self.rect.y = 390
def update(self, maze): time_test = pygame.time.get_ticks() if self.dead and not self.stop: if abs(self.last_frame - time_test) > 1000: self.last_frame = time_test self.death_index = (self.death_index + 1) % len(self.death_frames) self.image = self.death_frames[self.death_index] self.ghost = ImageRect(self.screen, self.image, self.SIZE * 2, self.SIZE * 2) self.go_home() if not self.dead and not self.stop and not self.power_pill: if abs(self.last_frame - time_test) > 1000: self.last_frame = time_test self.image_index = (self.image_index + 1) % len(self.images) self.image = self.images[self.image_index] self.ghost = ImageRect(self.screen, self.image, self.SIZE * 2, self.SIZE * 2) if not self.walk_channel.get_busy(): self.walk_channel.play(self.walk) if self.ghost_type == 1: self.inky_route(maze, time_test) if self.ghost_type == 2: self.blinky_route(maze, time_test) if self.ghost_type == 3: self.clyde_route(maze, time_test) if self.ghost_type == 4: self.pinky_route(maze, time_test) if not self.dead and not self.stop and self.power_pill: if not self.run_channel.get_busy(): self.run_channel.play(self.run) if not self.vuln_flag: self.vuln_flag = True self.image = self.blue_frames[0] self.ghost = ImageRect(self.screen, self.image, self.SIZE * 2, self.SIZE * 2) if abs(self.vulnerable_frame - time_test) > 5000: if abs(self.switch_frame - time_test) > self.flash: self.flash -= 200 self.switch_frame = time_test self.vulnerable_index = (self.vulnerable_index + 1) % len(self.blue_frames) self.image = self.blue_frames[self.vulnerable_index] self.ghost = ImageRect(self.screen, self.image, self.SIZE * 2, self.SIZE * 2) self.counter += 1 if self.counter == 6: self.flash = 1000 self.power_pill = False self.vuln_flag = False self.vulnerable_index = 0 self.counter = 0 if self.ghost_type == 1: self.inky_route(maze, time_test) if self.ghost_type == 2: self.blinky_route(maze, time_test) if self.ghost_type == 3: self.clyde_route(maze, time_test) if self.ghost_type == 4: self.pinky_route(maze, time_test) if self.stop: pass
class Pill(Sprite): def __init__(self, screen, rect): super(Pill, self).__init__() self.im = ImageRect(screen, "pill", 10, 10) self.screen = screen self.im.rect = rect self.rect = self.im.rect def update(self): self.im.blitme()
def create_blues(self, screen, sz): self.blues[0].append(self.blue) self.blue = ImageRect(screen, 'blue/blue_down_2', int(sz * 5.1), int(sz * 5.1)) self.blues[0].append(self.blue) self.blue = ImageRect(screen, 'blue/blue_left_1', int(sz * 5.1), int(sz * 5.1)) self.blues[1].append(self.blue) self.blue = ImageRect(screen, 'blue/blue_left_2', int(sz * 5.1), int(sz * 5.1)) self.blues[1].append(self.blue) self.blue = ImageRect(screen, 'blue/blue_right_1', int(sz * 5.1), int(sz * 5.1)) self.blues[2].append(self.blue) self.blue = ImageRect(screen, 'blue/blue_right_2', int(sz * 5.1), int(sz * 5.1)) self.blues[2].append(self.blue) self.blue = ImageRect(screen, 'blue/blue_up_1', int(sz * 5.1), int(sz * 5.1)) self.blues[3].append(self.blue) self.blue = ImageRect(screen, 'blue/blue_up_2', int(sz * 5.1), int(sz * 5.1)) self.blues[3].append(self.blue) self.blue = ImageRect(screen, 'scared/scared_1', int(sz * 5.1), int(sz * 5.1)) self.blues[4].append(self.blue) self.blue = ImageRect(screen, 'scared/scared_2', int(sz * 5.1), int(sz * 5.1)) self.blues[4].append(self.blue)
class Portal(Block): P_TYPE_1 = 1 P_TYPE_2 = 2 TYPE_1_COLOR = (0, 255, 255) TYPE_2_COLOR = (255, 128, 0) def __init__(self, screen, x, y, direction, maze, p_type=P_TYPE_1): self.screen = screen self.maze = maze self.direction = direction self.p_type = p_type if p_type == Portal.P_TYPE_1: self.images = ImageRect('blue-portal-bg.png', sheet=True, pos_offsets=[(0, 0, 32, 32), (32, 0, 32, 32), (64, 0, 32, 32), (0, 32, 32, 32), (32, 32, 32, 32), (64, 32, 32, 32), (0, 64, 32, 32)], resize=(self.maze.block_size, self.maze.block_size), animation_delay=250) image, _ = self.images.get_image() else: self.images = ImageRect('orange-portal-bg.png', sheet=True, pos_offsets=[(0, 0, 32, 32), (32, 0, 32, 32), (64, 0, 32, 32), (0, 32, 32, 32), (32, 32, 32, 32), (64, 32, 32, 32), (0, 64, 32, 32)], resize=(self.maze.block_size, self.maze.block_size), animation_delay=250) image, _ = self.images.get_image() super().__init__(x, y, maze.block_size, maze.block_size, image) def get_nearest_col(self): return (self.rect.x - (self.screen.get_width() // 5)) // self.maze.block_size def get_nearest_row(self): return (self.rect.y - (self.screen.get_height() // 12)) // self.maze.block_size def update(self): self.image = self.images.next_image() def blit(self): self.screen.blit(self.image, self.rect)
def create_pinks(self, screen, sz): self.pinks[0].append(self.pink) self.pink = ImageRect(screen, 'pink/pink_down_2', int(sz * 5.1), int(sz * 5.1)) self.pinks[0].append(self.pink) self.pink = ImageRect(screen, 'pink/pink_left_1', int(sz * 5.1), int(sz * 5.1)) self.pinks[1].append(self.pink) self.pink = ImageRect(screen, 'pink/pink_left_2', int(sz * 5.1), int(sz * 5.1)) self.pinks[1].append(self.pink) self.pink = ImageRect(screen, 'pink/pink_right_1', int(sz * 5.1), int(sz * 5.1)) self.pinks[2].append(self.pink) self.pink = ImageRect(screen, 'pink/pink_right_2', int(sz * 5.1), int(sz * 5.1)) self.pinks[2].append(self.pink) self.pink = ImageRect(screen, 'pink/pink_up_1', int(sz * 5.1), int(sz * 5.1)) self.pinks[3].append(self.pink) self.pink = ImageRect(screen, 'pink/pink_up_2', int(sz * 5.1), int(sz * 5.1)) self.pinks[3].append(self.pink) self.pink = ImageRect(screen, 'scared/scared_1', int(sz * 5.1), int(sz * 5.1)) self.pinks[4].append(self.pink) self.pink = ImageRect(screen, 'scared/scared_2', int(sz * 5.1), int(sz * 5.1)) self.pinks[4].append(self.pink)
def create_reds(self, screen, sz): self.reds[0].append(self.red) self.red = ImageRect(screen, 'red/red_down_2', int(sz * 5.1), int(sz * 5.1)) self.reds[0].append(self.red) self.red = ImageRect(screen, 'red/red_left_1', int(sz * 5.1), int(sz * 5.1)) self.reds[1].append(self.red) self.red = ImageRect(screen, 'red/red_left_2', int(sz * 5.1), int(sz * 5.1)) self.reds[1].append(self.red) self.red = ImageRect(screen, 'red/red_right_1', int(sz * 5.1), int(sz * 5.1)) self.reds[2].append(self.red) self.red = ImageRect(screen, 'red/red_right_2', int(sz * 5.1), int(sz * 5.1)) self.reds[2].append(self.red) self.red = ImageRect(screen, 'red/red_up_1', int(sz * 5.1), int(sz * 5.1)) self.reds[3].append(self.red) self.red = ImageRect(screen, 'red/red_up_2', int(sz * 5.1), int(sz * 5.1)) self.reds[3].append(self.red) self.red = ImageRect(screen, 'scared/scared_1', int(sz * 5.1), int(sz * 5.1)) self.reds[4].append(self.red) self.red = ImageRect(screen, 'scared/scared_2', int(sz * 5.1), int(sz * 5.1)) self.reds[4].append(self.red)
def create_oranges(self, screen, sz): self.oranges[0].append(self.orange) self.orange = ImageRect(screen, 'orange/orange_down_2', int(sz * 5.1), int(sz * 5.1)) self.oranges[0].append(self.orange) self.orange = ImageRect(screen, 'orange/orange_left_1', int(sz * 5.1), int(sz * 5.1)) self.oranges[1].append(self.orange) self.orange = ImageRect(screen, 'orange/orange_left_2', int(sz * 5.1), int(sz * 5.1)) self.oranges[1].append(self.orange) self.orange = ImageRect(screen, 'orange/orange_right_1', int(sz * 5.1), int(sz * 5.1)) self.oranges[2].append(self.orange) self.orange = ImageRect(screen, 'orange/orange_right_2', int(sz * 5.1), int(sz * 5.1)) self.oranges[2].append(self.orange) self.orange = ImageRect(screen, 'orange/orange_up_1', int(sz * 5.1), int(sz * 5.1)) self.oranges[3].append(self.orange) self.orange = ImageRect(screen, 'orange/orange_up_2', int(sz * 5.1), int(sz * 5.1)) self.oranges[3].append(self.orange) self.orange = ImageRect(screen, 'scared/scared_1', int(sz * 5.1), int(sz * 5.1)) self.oranges[4].append(self.orange) self.orange = ImageRect(screen, 'scared/scared_2', int(sz * 5.1), int(sz * 5.1)) self.oranges[4].append(self.orange)
def __init__(self, screen, num): super(Pipe, self).__init__() self.screen = screen self.type = "pipe" if num == 1: self.im_rect = ImageRect(screen, "media/images/pipe/pipe1", 64, 64) elif num == 2: self.im_rect = ImageRect(screen, "media/images/pipe/pipe2", 64, 96) elif num == 3: self.im_rect = ImageRect(screen, "media/images/pipe/pipe3", 64, 128) self.rect = self.im_rect.rect
class Dot(Sprite): def __init__(self, screen, rect): super(Dot, self).__init__() self.im = ImageRect(screen, "dot", 10, 10) self.screen = screen self.im.rect = rect self.rect = self.im.rect def update(self): self.im.blitme()
def __init__(self, screen, mazefile, brickfile, pointfile): self.screen = screen self.filename = mazefile with open(self.filename, 'r') as f: self.rows = f.readlines() self.bricks = [] self.points = [] sz = Maze.BRICK_SIZE self.brick = ImageRect(screen, brickfile, sz, sz) self.point = ImageRect(screen, pointfile, sz, sz) self.deltax = self.deltay = Maze.BRICK_SIZE self.build()
def __init__(self, screen, mazefile, brickfile, orangeportalfile, blueportalfile, shieldfile, pointfile, gatefile): self.screen = screen self.filename = mazefile with open(self.filename, 'r') as f: self.rows = f.readlines() self.bricks = [] self.shields = [] self.portals = [] self.points = [] self.gates = [] sz = Maze.BRICK_SIZE self.brick = ImageRect(screen, brickfile, sz, sz) self.shield = ImageRect(screen, shieldfile, sz * 2, sz * 2) self.blueportal = ImageRect(screen, blueportalfile, 5 * sz, 15 * sz) self.orangeportal = ImageRect(screen, orangeportalfile, 15 * sz, 5 * sz) self.point = ImageRect(screen, pointfile, int(sz * .9), int(sz * .9)) self.gate = ImageRect(screen, gatefile, sz, sz) self.deltax = self.deltay = Maze.BRICK_SIZE self.build()
def check_last_frame(self, time_test, images): if abs(self.last_frame - time_test) > 100: self.last_frame = time_test self.image_index = (self.image_index + 1) % len(images) self.image = images[self.image_index] self.player = ImageRect(self.screen, self.image, self.SIZE * 2, self.SIZE * 2)
def __init__(self, screen, mazefile, pink): self.screen = screen self.filename = mazefile with open(self.filename, "r") as f: self.rows = f.readlines() self.pinkGhosts = [ 'images/pinkGhost0.png', 'images/pinkGhost1.png', 'images/pinkGhost2.png', 'images/pinkGhost3.png' ] self.pinks = [] size = BlueGhost.P1_SIZE self.pink = ImageRect(screen, pink, size, size) r = self.pink.rect w, h = r.width, r.height # x, y , width, height self.pinks.append(pygame.Rect(525, 630, w, h)) self.x_direction = -.5 self.y_direction = -.5 self.collide_x = False for rect in self.pinks: self.x = float(rect.x) self.y = float(rect.y)
def __init__(self, screen, mazefile, p1): self.screen = screen self.filename = mazefile with open(self.filename, "r") as f: self.rows = f.readlines() self.blueGhosts = [ 'images/BlueGhost0.png', 'images/BlueGhost1.png', 'images/BlueGhost2.png', 'images/BlueGhost3.png' ] self.p1s = [] size = BlueGhost.P1_SIZE self.curFrame = Timer(self.blueGhosts) self.p1 = ImageRect(screen, p1, size, size) r = self.p1.rect w, h = r.width, r.height # x, y , width, height self.p1s.append(pygame.Rect(150, 120, w, h)) self.x_direction = .5 self.y_direction = .5 self.collide_x = False for rect in self.p1s: self.x = float(rect.x) self.y = float(rect.y)
def loadimages(self, color): frames = [] filename = 'portal_' + color for sz in range(Portal.NUM_FRAMES): size = int(5 * sz) frames.append(ImageRect(self.screen, filename, height=size, width=size)) return frames
def prep_player_lives(self): score_str = 'Lives Left: ' self.text = self.font.render(score_str, True, self.WHITE, self.BLACK) self.rtext = self.text.get_rect() self.rtext.bottom = self.screen_rect.bottom - self.SIZE self.rtext.x = self.screen_rect.width / 2 - self.SIZE * 4 self.images = ['pacman2'] self.image = self.images[0] self.live = ImageRect(self.screen, self.image, self.SIZE * 2, self.SIZE * 2) r = self.live.rect w, h = r.width, r.height self.lives_1.append(pygame.Rect(0, 0, w, h)) self.lives_2.append(pygame.Rect(0, 0, w, h)) self.lives_3.append(pygame.Rect(0, 0, w, h)) for rect in self.lives_1: rect.x = self.screen_rect.width / 2 + self.SIZE * 3 rect.y = self.screen_rect.bottom - self.SIZE * 2.5 for rect in self.lives_2: rect.x = self.screen_rect.width / 2 + self.SIZE * 5 rect.y = self.screen_rect.bottom - self.SIZE * 2.5 for rect in self.lives_3: rect.x = self.screen_rect.width / 2 + self.SIZE * 7 rect.y = self.screen_rect.bottom - self.SIZE * 2.5
def __init__(self, screen): super(BreakBrick, self).__init__() self.screen = screen self.type = "breakable" self.im_rect = ImageRect(screen, "media/images/brick/platform", 32, 32) self.rect = self.im_rect.rect self.opened = False # If Mario hits the bricks underside, this becomes true
def __init__(self, screen, mazefile): """Initialize pacman and set its starting position""" super(Blue, self).__init__() self.screen = screen self.filename = mazefile with open(self.filename, 'r') as f: self.rows = f.readlines() self.sz = Blue.BLUE_SIZE self.blues = [] for x in range(5): self.blues.append([]) self.blue = ImageRect(screen, 'blue/blue_down_1', int(self.sz * 5.1), int(self.sz * 5.1)) self.create_blues(self.screen, self.sz) self.deltax = self.deltay = self.BRICK_SIZE self.starting_centerx = 0 self.starting_centery = 0 self.build() self.centerx = float(self.blue.rect.centerx) self.centery = float(self.blue.rect.centery) # Movement flag self.moving_right = False self.moving_left = False self.moving_up = False self.moving_down = False self.index = 0 self.i = 0 # used for debug traversing image self.scared = False
def __init__(self, screen, mazefile, brickfile, shieldfile, pacfile, powerfile, tabletfile, clydefile, pinkyfile, inkyfile, blinkyfile, stats): self.screen = screen self.filename = mazefile self.stats = stats with open(self.filename, 'r') as f: self.rows = f.readlines() self.score_text = Text(self.screen, "SCORE:", 50, 50, 20, 20, (255, 255, 255)) self.lives_text = Text(self.screen, "LIVES:", 50, 50, 300, 20, (255, 255, 255)) self.shields = [] self.bricks = [] self.powerpills = [] self.tablets = [] self.life = [None] * 5 self.sz = Maze.BRICK_SIZE self.tsz = Maze.TABLET_SIZE self.psz = Maze.PAC_SIZE self.brick = ImageRect(screen, brickfile, self.sz, self.sz) self.shield = ImageRect(screen, shieldfile, self.sz, self.sz) self.pacman = ImageRect(screen, pacfile, self.psz, self.psz) self.clyde = ImageRect(screen, clydefile, self.sz * 2, self.sz * 2) self.pinky = ImageRect(screen, pinkyfile, self.sz * 2, self.sz * 2) self.inky = ImageRect(screen, inkyfile, self.sz * 2, self.sz * 2) self.blinky = ImageRect(screen, blinkyfile, self.sz * 2, self.sz * 2) self.powerpill = ImageRect(screen, powerfile, self.sz, self.sz) self.tablet = ImageRect(screen, tabletfile, self.tsz, self.tsz) self.life_image = pygame.image.load('images/left_pac_1.png') self.deltax = self.deltay = Maze.BRICK_SIZE self.nodeDict = {} self.currentnodeDict = {} self.nodeXYDict = {} self.XYnodeDict = {} self.pacman_init_x = 0 self.pacman_init_y = 0 self.clyde_init_x = 0 self.clyde_init_y = 0 self.pinky_init_x = 0 self.pinky_init_y = 0 self.inky_init_x = 0 self.inky_init_y = 0 self.blinky_init_x = 0 self.blinky_init_y = 0 self.build()
def __init__(self, screen, num): super(StairBrick, self).__init__() self.screen = screen self.im_rect = ImageRect(screen, "media/images/brick/stair_brick_" + str(num), 32, 32 * num) self.type = "stair_" + str(num) self.rect = self.im_rect.rect
def __init__(self, screen, mazefile, brickfile):#, portalfile, shieldfile, pointfile): self.screen = screen self.filename = mazefile with open(self.filename, "r") as f: self.rows = f.readlines() self.bricks = [] sz = Maze.BRICK_SIZE self.brick = ImageRect(screen, brickfile, sz, sz) # screen, square, height, width self.rect = self.brick.get_rect() self.deltax = self.deltay = Maze.BRICK_SIZE self.build()