def addball(self): if self.level==1: level01=level1.level() else: level01=level2.level() layout=level01.getlayout() img_list=level01.getsprites() x_offset=BLOCK_SIZE/2 y_offset=BLOCK_SIZE/2 centerpoint=[(2*BLOCK_SIZE)+x_offset,(3*BLOCK_SIZE)+y_offset] ball=fireball(centerpoint,img_list[level01.FIREBALL]) self.fireball_sprites.add(ball)
def addball(self): if self.level == 1: level01 = level1.level() else: level01 = level2.level() layout = level01.getlayout() img_list = level01.getsprites() x_offset = BLOCK_SIZE / 2 y_offset = BLOCK_SIZE / 2 centerpoint = [(2 * BLOCK_SIZE) + x_offset, (3 * BLOCK_SIZE) + y_offset] ball = fireball(centerpoint, img_list[level01.FIREBALL]) self.fireball_sprites.add(ball)
def LoadSprites(self): x_offset = BLOCK_SIZE / 2 y_offset = BLOCK_SIZE / 2 if self.level == 1: level01 = level1.level() else: level01 = level2.level() layout = level01.getlayout() img_list = level01.getsprites() self.coin_sprites = pygame.sprite.RenderUpdates() self.queen_sprites = pygame.sprite.RenderUpdates() self.wall_sprites = pygame.sprite.RenderUpdates() self.ladder_sprites = pygame.sprite.RenderUpdates() self.fireball_sprites = pygame.sprite.RenderUpdates() for y in xrange(len(layout)): """Select the layout based on 2-d matrix in the level file""" for x in xrange(len(layout[y])): centerpoint = [(x * BLOCK_SIZE) + x_offset, (y * BLOCK_SIZE) + y_offset] if layout[y][x] == level01.WALL: wall = basicsprite.sprite(centerpoint, img_list[level01.WALL]) self.wall_sprites.add(wall) elif layout[y][x] == level01.PLAYER: self.player = player(centerpoint, img_list[level01.PLAYER]) elif layout[y][x] == level01.COIN: coin = basicsprite.sprite(centerpoint, img_list[level01.COIN]) self.coin_sprites.add(coin) elif layout[y][x] == level01.LADDER: ladder = basicsprite.sprite(centerpoint, img_list[level01.LADDER]) self.ladder_sprites.add(ladder) elif layout[y][x] == level01.DONKEY: self.donkey = donkey(centerpoint, img_list[level01.DONKEY]) elif layout[y][x] == level01.FIREBALL: ball = fireball(centerpoint, img_list[level01.FIREBALL]) self.fireball_sprites.add(ball) elif layout[y][x] == level01.QUEEN: queen = basicsprite.sprite(centerpoint, img_list[level01.QUEEN]) self.queen_sprites.add(queen) self.player_sprites = pygame.sprite.RenderUpdates((self.player)) self.donkey_sprites = pygame.sprite.RenderPlain((self.donkey))
def LoadSprites(self): x_offset=BLOCK_SIZE/2 y_offset=BLOCK_SIZE/2 if self.level==1: level01=level1.level() else: level01=level2.level() layout=level01.getlayout() img_list=level01.getsprites() self.coin_sprites=pygame.sprite.RenderUpdates() self.queen_sprites=pygame.sprite.RenderUpdates() self.wall_sprites=pygame.sprite.RenderUpdates() self.ladder_sprites=pygame.sprite.RenderUpdates() self.fireball_sprites=pygame.sprite.RenderUpdates() for y in xrange(len(layout)): """Select the layout based on 2-d matrix in the level file""" for x in xrange(len(layout[y])): centerpoint=[(x*BLOCK_SIZE)+x_offset,(y*BLOCK_SIZE)+y_offset] if layout[y][x]==level01.WALL: wall=basicsprite.sprite(centerpoint,img_list[level01.WALL]) self.wall_sprites.add(wall) elif layout[y][x]==level01.PLAYER: self.player=player(centerpoint,img_list[level01.PLAYER]) elif layout[y][x]==level01.COIN: coin=basicsprite.sprite(centerpoint,img_list[level01.COIN]) self.coin_sprites.add(coin) elif layout[y][x]==level01.LADDER: ladder=basicsprite.sprite(centerpoint,img_list[level01.LADDER]) self.ladder_sprites.add(ladder) elif layout[y][x]==level01.DONKEY: self.donkey=donkey(centerpoint,img_list[level01.DONKEY]) elif layout[y][x]==level01.FIREBALL: ball=fireball(centerpoint,img_list[level01.FIREBALL]) self.fireball_sprites.add(ball) elif layout[y][x]==level01.QUEEN: queen=basicsprite.sprite(centerpoint,img_list[level01.QUEEN]) self.queen_sprites.add(queen) self.player_sprites=pygame.sprite.RenderUpdates((self.player)) self.donkey_sprites=pygame.sprite.RenderPlain((self.donkey))