示例#1
0
 def createExit(self, j, i):
     self.stageScale = 50
     x = self.stageScale * (j)
     y = self.stageScale * (i)
     sprite = Platform()
     sprite.rect = pygame.Rect((x, y), (self.stageScale, self.stageScale))
     sprite.image = self.imageDictionary["exit"]
     sprite.image = pygame.transform.scale(sprite.image, (self.stageScale, self.stageScale))
                                            
     self.exitGroup.add(sprite);
示例#2
0
文件: level.py 项目: 450W16/MODACT
	def parse_map(self, filename, enemies, callback):
		with open(path.join(get_levels_dir(), filename), "r") as f:
			x = y = 0
			for line in f:
				for block in line.rstrip():
					if block != " ":
						#need a trigger block image
						if block in enemies:
							callback(self, enemies[block](40, 40, x, y))
						elif block == "E":
							trigger = Trigger(x, y)
							self.trigger_list.add(trigger)
						elif block == "w":
							walltrigger = WallTrigger(x, y)
							self.wallTrigger_list.add(walltrigger)
						elif block == "^":
							moving_platformsUD = MplatformUD(x, y)
							self.platform_list.add(moving_platformsUD)
						elif block == "v":
							vine = Vine(x, y)
							self.platform_list.add(vine)
						elif block == "V":
							vinetrigger = VineTrigger(x, y)
							self.vinetrigger_list.add(vinetrigger)
						elif block == ">":
							moving_platformsLR = MplatformLR(x, y)
							self.platform_list.add(moving_platformsLR)

						elif block == "P":
							self.Px = x
							self.Py = y 
						elif block == "A":
							self.Ax = x
							self.Ay = y 
						elif block == "y":
							self.ground_level = y
						else:
							platform = Platform(x, y)
							platform.image = self.mapdict[block]
							self.platform_list.add(platform)
					x += BLOCK_WIDTH


				if x > self.level_width:
					self.level_width = x
				x = 0
				y += BLOCK_HEIGHT

			self.level_height = y
示例#3
0
    def createSprite(self,lines, j, i, character):
        self.stageScale = 50
        
        # Para que player aparezca en esquina superior izquierda
        x = self.stageScale * (j)
        y = self.stageScale * (i)

        sprite = Platform()
        sprite.i = i
        sprite.j = j

        if character == "a":
            sprite.image = self.imageDictionary["topCement"]
            sprite.imagen2 = self.imageDictionary["topCement"]
        elif character == "t":
            sprite.image = self.imageDictionary["lowEarth"]
            sprite.imagen2 = self.imageDictionary["lowEarth"]
        elif character == "n":
            sprite.image = self.imageDictionary["grass"]
            sprite.imagen2 = self.imageDictionary["grass"]
        elif character == "ñ":
            sprite.image = self.imageDictionary["topGrass"]
            sprite.imagen2 = self.imageDictionary["topGrass"]
        elif character == "s":
            sprite.image = self.imageDictionary["sand"]
            sprite.imagen2 = self.imageDictionary["sand"]
        elif character == "b":##################
            sprite.image = self.imageDictionary["blueAlpha"]##################
            sprite.imagen2 = self.imageDictionary["blue"]##################
            sprite.color = "Blue"     ##################
        elif character == 'r':##################
            sprite.image = self.imageDictionary["lava"]##################
            sprite.imagen2 = self.imageDictionary["lava"]##################
            #sprite.color = "Green"##################
        elif character == "O":
             sprite.image = self.imageDictionary["blueAlpha"]
             sprite.imagen2 = self.imageDictionary["blue"]



             sprite.id = "Horizontal"
             sprite.color = "Blue" 


        elif character == "P":
            sprite.image = self.imageDictionary["greenAlpha"]
            sprite.imagen2 = self.imageDictionary["green"]
            #sprite.delta_x = 5
            #sprite.lim_x = 20
            #sprite.delta_y = 5
            #sprite.lim_y = 20
            #sprite.delta_y = 5
            #sprite.tipo_movimiento = "0"
            sprite.id = "Horizontal"
            sprite.color = "Green"
        elif character == "Q":
            sprite.image = self.imageDictionary["blueAlpha"]
            sprite.imagen2 = self.imageDictionary["blue"]

            sprite.id = "Vertical"
            sprite.color = "Blue" 
        elif character == "F":
            sprite.image = self.imageDictionary["greenAlpha"]
            sprite.imagen2 = self.imageDictionary["green"]
            sprite.id = "Vertical"
            sprite.color = "Green"    

        else: 
            sprite.image = self.imageDictionary["grass"]
            sprite.imagen2 = self.imageDictionary["grass"]
            sprite.color = "Green"

        if character == "P" or character == "O":
            colorlargo = self.createPlatform(lines,j,i,"H")
            color = colorlargo[0]
            scale_x = colorlargo[1]
            scale_y = colorlargo[2]
            sprite.color = color
            #scale = 2
            x = self.stageScale * (j)
            y = self.stageScale * (i)
            sprite.scale_x = scale_x
            sprite.scale_y = scale_y
            sprite.x_scale = self.stageScale *scale_x
            sprite.y_scale = self.stageScale*scale_y
            sprite.image = pygame.transform.scale(sprite.image, (int(scale_x*self.stageScale), int(scale_y*self.stageScale)))
            sprite.imagen2 = pygame.transform.scale(sprite.imagen2, (int(scale_x*self.stageScale), int(scale_y*self.stageScale)))
            sprite.rect = pygame.Rect((x, y), (scale_x*self.stageScale, scale_y*self.stageScale))
            sprite.imagenoriginal = sprite.image
        elif character == "F" or character == "Q":
            sprite.x_scale = self.stageScale 
            sprite.y_scale = self.stageScale
            sprite.image = pygame.transform.scale(sprite.image, (int(0.5*self.stageScale), 5*self.stageScale))
            sprite.imagen2 = pygame.transform.scale(sprite.imagen2, (int(0.5*self.stageScale), 5*self.stageScale))
            sprite.rect = pygame.Rect((x, y), (int(0.5*self.stageScale), 5*self.stageScale))
            sprite.imagenoriginal = sprite.image   
        else:
            sprite.x_scale = self.stageScale 
            sprite.y_scale = self.stageScale
            sprite.image = pygame.transform.scale(sprite.image, (self.stageScale, self.stageScale))
            sprite.imagen2 = pygame.transform.scale(sprite.imagen2, (self.stageScale, self.stageScale))
            sprite.rect = pygame.Rect((x, y), (self.stageScale, self.stageScale))
            sprite.imagenoriginal = sprite.image

        # Define rectangulos que serviran para delimitar etapa y limitar movimiento de la camara
        if i == 0 and j == 0:
            self.firstRect = pygame.Rect((x, y), (self.stageScale, self.stageScale))
        elif i == (self.height - 1) and j == (self.width - 1):
            self.lastRect = pygame.Rect((x, y), (self.stageScale, self.stageScale))
        sprite.colororiginal = sprite.color

        self.group.add(sprite)