Ejemplo n.º 1
0
 def generatefire(self):
     if self.__level==1:
         level = level01()
         layout = level.getLayout()
         img_list = level.getSprites()
     elif self.__level ==2 :
         level = level02()
         layout = level.getLayout()
         img_list = level.getSprites()
     centerPoint = [108,180]
     self.fire = fire(centerPoint,img_list[level.FIRE])
     self.firelist.append(pygame.sprite.RenderPlain(self.fire))
Ejemplo n.º 2
0
	def loadsprite(self):
	    x_offset = (BRICKSIZE/2)
            y_offset = (BRICKSIZE/2)
            if self.__level == 1 :
                level = level01()
                layout = level.getLayout()
                img_list = level.getSprites()
            elif self.__level ==2 :
                level = level02()
                layout = level.getLayout()
                img_list = level.getSprites()  
            self.brick_sprites = pygame.sprite.Group()
            self.coin_sprites = pygame.sprite.Group()
            self.ladder_sprites = pygame.sprite.Group()
            self.brokenladder_sprites = pygame.sprite.Group()
            for y in xrange(len(layout)):
                for x in xrange(len(layout[y])):
                    centerPoint = [(x*BRICKSIZE)+x_offset,(y*BRICKSIZE+y_offset)]#calculated centerpoint becoz we have to place the center exactly on the position of matrix
                    if layout[y][x]==level.BRICK:
                        brick = Sprite(centerPoint, img_list[level.BRICK])
                        self.brick_sprites.add(brick)
                    elif layout[y][x]==level.PLAYER:
                        self.player = player(centerPoint,img_list[level.PLAYER])
                    elif layout[y][x]==level.COIN:
                        coin = Sprite(centerPoint, img_list[level.COIN])
                        self.coin_sprites.add(coin)
                    elif layout[y][x]==level.LEFT_LADDER :
                        ladder = Sprite(centerPoint , img_list[level.LEFT_LADDER])
                        self.ladder_sprites.add(ladder) 
                    elif layout[y][x]==level.RIGHT_LADDER :
                        ladder = Sprite(centerPoint , img_list[level.RIGHT_LADDER])
                        self.ladder_sprites.add(ladder)
                    elif layout[y][x] == level.TANK:
                        self.tank = Sprite(centerPoint,img_list[level.TANK])
                    elif layout[y][x] == level.MONSTER :
                        self.monster = monster(centerPoint,img_list[level.MONSTER])
                    elif layout[y][x] == level.FIRE :
                        self.fire = fire(centerPoint,img_list[level.FIRE])
                    elif layout[y][x] == level.QUEEN :
                        self.queen = Sprite(centerPoint , img_list[level.QUEEN])
                    elif layout[y][x] == level.BROKENLADDERLEFT :
                        self.broke = Sprite(centerPoint , img_list[level.BROKENLADDERLEFT])
                        self.brokenladder_sprites.add(self.broke)
                    elif layout[y][x] == level.BROKENLADDERRIGHT :
                        self.broke = Sprite(centerPoint , img_list[level.BROKENLADDERRIGHT])
                        self.brokenladder_sprites.add(self.broke)
            self.player_sprites = pygame.sprite.RenderPlain(self.player)
            self.monster_sprites = pygame.sprite.RenderPlain(self.monster)    
            self.firelist.append(pygame.sprite.RenderPlain(self.fire))   
            self.tank_sprites = pygame.sprite.RenderPlain(self.tank)
            self.queen_sprites = pygame.sprite.RenderPlain(self.queen)