def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load("Space(level1).png").convert() self.background.set_colorkey(constants.BLACK) self.level_limit = -800 level = [ [platforms.STONE_PLATFORM_MIDDLE, 70, 200], [platforms.STONE_PLATFORM_MIDDLE, 200, 500], [platforms.STONE_PLATFORM_MIDDLE, 470, 300], [platforms.STONE_PLATFORM_MIDDLE, 1200, 600], [platforms.STONE_PLATFORM_MIDDLE, 1270, 600], [platforms.STONE_PLATFORM_MIDDLE, 1340, 600], [platforms.EXIT_SIGN, 1410, 530], [platforms.STONE_PLATFORM_MIDDLE, 1410, 600], [platforms.STONE_PLATFORM_MIDDLE, 1480, 600], [platforms.STONE_PLATFORM_MIDDLE, 1550, 600], [platforms.STONE_PLATFORM_MIDDLE, 1620, 600], [platforms.STONE_PLATFORM_MIDDLE, 1690, 600], [platforms.STONE_PLATFORM_MIDDLE, 1740, 600], [platforms.STONE_PLATFORM_MIDDLE, 1750, 560], [platforms.STONE_PLATFORM_MIDDLE, 1750, 520], [platforms.STONE_PLATFORM_MIDDLE, 1750, 480] ] for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 290 block.rect.y = 101 block.boundary_top = 100 block.boundary_bottom = 649 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 550 block.rect.y = 400 block.boundary_left = 551 block.boundary_right = 1100 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load("background_02.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -1000 # Array with type of platform, and x, y location of the platform. level = [ [platforms.STONE_PLATFORM_LEFT, 500, 550], [platforms.STONE_PLATFORM_MIDDLE, 570, 550], [platforms.STONE_PLATFORM_RIGHT, 640, 550], [platforms.STONE_PLATFORM_LEFT, 1120, 280], [platforms.STONE_PLATFORM_MIDDLE, 1190, 280], [platforms.STONE_PLATFORM_MIDDLE, 1190, 350], [platforms.STONE_PLATFORM_MIDDLE, 1190, 450], [platforms.STONE_PLATFORM_MIDDLE, 1190, 550], [platforms.STONE_PLATFORM_RIGHT, 1260, 280], ] # Go through the array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1500 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 900 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block)
def createLevel(self): self.background = pygame.image.load(BACKGROUND_03).convert() self.background.set_colorkey(WHITE) self.level_limit = -1000 self.level = [[platforms.GRASS_LEFT, 0, 500]] for i in range(1, 5): self.level.append([platforms.GRASS_MIDDLE, 70 * i, 500]) self.level.append([platforms.GRASS_RIGHT, 350, 500]) for i in range(1, 10): self.level.append( [platforms.GRASS_MIDDLE, 350 + 70 * i, 500 - 50 * i]) for i in range(1, 10): self.level.append( [platforms.GRASS_MIDDLE, 1500 + 70 * i, 500 - 50 * i]) self.add_platform() for i in range(1, 3): block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1100 + 100 * i block.rect.y = 300 + 100 * i block.boundary_top = 100 + 70 * i block.boundary_bottom = 500 + 70 * i block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block)
def createLevel(self): self.background = pygame.image.load(BACKGROUND_05).convert() self.level = [[platforms.GRASS_LEFT, 0, 500]] for i in range(1, 20): self.level.append([platforms.GRASS_MIDDLE, 70 * i, 500]) self.level.append([platforms.GRASS_RIGHT, 70 * i, 500]) for i in range(1, 5): self.level.append( [platforms.STONE_PLATFORM_MIDDLE, 240 + 70 * i, 580 - 100 * i]) self.add_platform() block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1000 block.rect.y = 60 block.boundary_top = 290 block.boundary_bottom = 500 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) self.spawn()
def __init__(self, player, bullet, drag): Level.__init__(self, player, bullet, drag) self.background = pygame.image.load('pokeclouds.png').convert() self.background.set_colorkey(constants.white) self.level_limit = -1000 level = [[platforms.METAL_BLOCK3,0, 550 ], [platforms.METAL_BLOCK1, 132, 550], [platforms.METAL_BLOCK2, 264, 550], ] for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # moving block = platforms.MovingPlatform(platforms.METAL_RECT_THIN1) block.rect.x = 1500 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): # create level 1 # call the constructor Level.__init__(self, player) self.background = pygame.image.load('jetman.png').convert() self.background.set_colorkey(constants.white) self.level_limit = -5500 # Array with type of platform, and x, y location of the platform level = [ [platforms.BLUE_PLATFORM_END, 535, 500], [platforms.BLUE_PLATFORM_MIDDLE, 570, 500], [platforms.BLUE_PLATFORM_END, 610, 500], [platforms.BLUE_PLATFORM_END, 800, 400], [platforms.BLUE_PLATFORM_END, 835, 400], [platforms.BLUE_PLATFORM_MIDDLE, 870, 400], [platforms.BLUE_PLATFORM_END, 910, 400], [platforms.BLUE_PLATFORM_END, 945, 400], [platforms.BLUE_PLATFORM_END, 1035, 500], [platforms.BLUE_PLATFORM_MIDDLE, 1070, 500], [platforms.BLUE_PLATFORM_END, 1105, 500], [platforms.YELLOW_BRICK, 1120, 280], [platforms.YELLOW_BRICK, 1152, 280], [platforms.YELLOW_BRICK, 1184, 280], [platforms.GRASS_LEFT, 1700, 240], [platforms.GRASS_MIDDLE, 1730, 240], [platforms.GRASS_MIDDLE, 1760, 240], [platforms.GRASS_MIDDLE, 1790, 240], [platforms.GRASS_RIGHT, 1820, 240], [platforms.YELLOW_BRICK, 1718, 425], [platforms.YELLOW_BRICK, 1750, 425], [platforms.YELLOW_BRICK, 1782, 425], [platforms.BLUE_PLATFORM_END, 1915, 185], [platforms.BLUE_PLATFORM_END, 1950, 185], [platforms.BLUE_PLATFORM_END, 1985, 185], [platforms.STONE, 1891, 380], [platforms.STONE, 1922, 380], ] # Go through array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 1. """ # call the parent constructor Level.__init__(self, player) self.background = pygame.image.load("background_01.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -2500 # Array with type of platform, and x, y location of the platform. level = [ [platforms.GRASS_LEFT, 500, 500], [platforms.GRASS_MIDDLE, 570, 500], [platforms.GRASS_RIGHT, 640, 500], [platforms.GRASS_LEFT, 800, 400], [platforms.GRASS_MIDDLE, 870, 400], [platforms.GRASS_RIGHT, 940, 400], [platforms.GRASS_LEFT, 1000, 500], [platforms.GRASS_MIDDLE, 1070, 500], [platforms.GRASS_RIGHT, 1140, 500], [platforms.STONE_PLATFORM_LEFT, 1120, 280], [platforms.STONE_PLATFORM_MIDDLE, 1190, 280], [platforms.STONE_PLATFORM_RIGHT, 1260, 280], ] # Go through the array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # add array of features that can't cause collisions level = [ [platforms.DOOR_BASE, 870, 330], [platforms.DOOR_TOP, 870, 290], ] for feature in level: block = platforms.Feature(feature[0]) block.rect.x = feature[1] block.rect.y = feature[2] block.player = self.player self.feature_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def insert_up_down(self,x,y): block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = x block.rect.y = y block.boundary_top = random.randrange(100,250) block.boundary_bottom = random.randrange(550,600) block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player, enemy): Level.__init__(self, player, enemy) self.background = pygame.image.load("images/castle.png").convert() #101,5,48,150 self.background.set_colorkey(constants.WHITE) self.level_limit = -2500 # Array com o tipo de plataforma e coordenadas (x,y) para localização level = [ [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-48, constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*2), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*3), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*4), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*5), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*6), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*7), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*8), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*9), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*10), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*11), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*12), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*13), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*14), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*15), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*16), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*17), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*18), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*19), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*20), constants.SCREEN_HEIGHT-12], [platforms.STONE_PLATFORM_MIDDLE, constants.SCREEN_WIDTH-(48*21), constants.SCREEN_HEIGHT-12], ] # Passa pelo array e adiciona plataformas for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player block.enemy = self.enemy self.platform_list.add(block) # Adiciona uma plataforma móvel block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.enemy = self.enemy block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load("background_01.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -2500 # Array with type of platform, and x, y location of the platform. level = [ #Main platforms ingame [platforms.GRASS_LEFT, 500, 530], [platforms.GRASS_MIDDLE, 570, 530], [platforms.GRASS_RIGHT, 640, 530], [platforms.GRASS_LEFT, 800, 400], [platforms.GRASS_MIDDLE, 870, 400], [platforms.GRASS_MIDDLE, 940, 400], [platforms.GRASS_RIGHT, 1010, 400], [platforms.GRASS_LEFT, 1000, 530], [platforms.GRASS_MIDDLE, 1070, 530], [platforms.GRASS_RIGHT, 1140, 530], #[platforms.STONE_PLATFORM_LEFT, 1120, 280], #[platforms.STONE_PLATFORM_MIDDLE, 1190, 280], #[platforms.STONE_PLATFORM_RIGHT, 1260, 280], #Other ones i'm adding as a test #[platforms.GRASS_MIDDLE, 0, 550], #[platforms.GRASS_MIDDLE, 0, 400], #[platforms.STONE_PLATFORM_LEFT, 1800, 300], #[platforms.STONE_PLATFORM_MIDDLE, 1970, 300], ] # Go through the array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 10 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): # Call the parent constructor Level.__init__(self, player) background_path = directory_info.base_directory + \ "/images/green-hill-zone/result/background.png" self.background = pygame.image.load(background_path).convert() size = [constants.SCREEN_WIDTH + 3000, constants.SCREEN_HEIGHT] self.background = pygame.transform.scale(self.background, size) self.background.set_colorkey(constants.WHITE) self.level_limit = -2500 # Array with type of platform, and x, y location of the platform. '''level = [ [platforms.GRASS_LEFT, 500, 500], [platforms.GRASS_MIDDLE, 570, 500], [platforms.GRASS_RIGHT, 640, 500], [platforms.GRASS_LEFT, 800, 400], [platforms.GRASS_MIDDLE, 870, 400], [platforms.GRASS_RIGHT, 940, 400], [platforms.GRASS_LEFT, 1000, 500], [platforms.GRASS_MIDDLE, 1070, 500], [platforms.GRASS_RIGHT, 1140, 500], [platforms.STONE_PLATFORM_LEFT, 1120, 280], [platforms.STONE_PLATFORM_MIDDLE, 1190, 280], [platforms.STONE_PLATFORM_RIGHT, 1260, 280], [platforms.FLOOR, 300, 520], ]''' level = [[platforms.FLOOR_1, 200, 485, 15], [platforms.FLOOR_1, 1000, 200, 1]] # Go through the array above and add platforms for platform in level: for i in range(0, platform[3]): block = platforms.Platform(platform[0]) block.rect.x = platform[1] + 4.2 * i * block.x0 block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.FLOOR_1) block.rect.x = 1350 block.rect.y = 340 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load( \ "images/old-textures/background_01.png").convert() #size = [constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT] #self.background = pygame.transform.scale(self.background, size) self.background.set_colorkey(constants.WHITE) self.level_limit = -2500 # Array with type of platform, and x, y location of the platform. level = [ [platforms.GRASS_LEFT, 500, 500], [platforms.GRASS_MIDDLE, 570, 500], [platforms.GRASS_RIGHT, 640, 500], [platforms.GRASS_LEFT, 800, 400], [platforms.GRASS_MIDDLE, 870, 400], [platforms.GRASS_RIGHT, 940, 400], [platforms.GRASS_LEFT, 1000, 500], [platforms.GRASS_MIDDLE, 1070, 500], [platforms.GRASS_RIGHT, 1140, 500], [platforms.STONE_PLATFORM_LEFT, 1120, 280], [platforms.STONE_PLATFORM_MIDDLE, 1190, 280], [platforms.STONE_PLATFORM_RIGHT, 1260, 280], ] # Go through the array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load("background_01.png").convert() self.background = pygame.transform.scale(self.background, (3840, HEIGHT)) self.background.set_colorkey(constants.WHITE) self.level_limit = -6200 # Array with type of platform, and x, y location of the platform. level = [ [platforms.GRASS, 570, 500 * 2], [platforms.GRASS, 870, 400 * 2], [platforms.GRASS, 1070, 500 * 2], [platforms.STONE_PLATFORM, 1190, 280 * 2], ] # Go through the array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MOVE) block.rect.x = 1350 block.rect.y = int(280 * 1.64) block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block) # Add a custom moving mob block = mobs.MovingMob(mobs.MOB1) block.rect.x = 1250 block.rect.y = 530 block.boundary_left = 1250 block.boundary_right = 1500 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load("mountains1_longer.png").convert() # self.background = pygame.image.load("background_01.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -2000 # Array with type of platform, and x, y location of the platform. level = [ [platforms.SNOW_LEFT, 500, 400], [platforms.SNOW_MIDDLE, 570, 400], [platforms.SNOW_RIGHT, 640, 400], [platforms.SNOW_LEFT, 800, 270], [platforms.SNOW_MIDDLE, 870, 270], [platforms.SNOW_RIGHT, 940, 270], # [platforms.SNOW_LEFT, 1000, 500], # [platforms.SNOW_MIDDLE, 1070, 500], # [platforms.SNOW_RIGHT, 1140, 500], [platforms.STONE_PLATFORM_LEFT, 1750, 270], [platforms.STONE_PLATFORM_MIDDLE, 1820, 270], # [platforms.STONE_PLATFORM_RIGHT, 1790, 450], ] # Go through the array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1180 block.rect.y = 280 block.boundary_left = 1180 block.boundary_right = 1600 block.change_x = 3 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load("background_1.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -2500 # Array with type of platform, and x, y location of the platform. ## SHOULD REPLACE WITH STUFF OURSELVES level = [ [platforms.GRASS_LEFT, 500, 500], [platforms.GRASS_MIDDLE, 570, 500], [platforms.GRASS_RIGHT, 640, 500], [platforms.GRASS_LEFT, 800, 400], [platforms.GRASS_MIDDLE, 870, 400], [platforms.GRASS_RIGHT, 940, 400], [platforms.GRASS_LEFT, 1000, 500], [platforms.GRASS_MIDDLE, 1070, 500], [platforms.GRASS_RIGHT, 1140, 500], [platforms.STONE_PLATFORM_LEFT, 1120, 280], [platforms.STONE_PLATFORM_MIDDLE, 1190, 280], [platforms.STONE_PLATFORM_RIGHT, 1260, 280], ] # Go through the array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block) '''setup_enemies(self)
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load("img/background_01.png").convert() #self.background.set_colorkey(constants.WHITE) self.level_limit = -2500 # Array with type of platform, and x, y location of the platform. level = [ [platforms.TRS_PLATFORM, 250, 500], [platforms.TRS_PLATFORM, 250, 400], [platforms.STD_PLATFORM, 500, 500], [platforms.STD_PLATFORM, 570, 500], [platforms.STD_PLATFORM, 640, 500], [platforms.STD_PLATFORM, 800, 400], [platforms.STD_PLATFORM, 870, 400], [platforms.STD_PLATFORM, 940, 400], [platforms.STD_PLATFORM, 1000, 500], [platforms.STD_PLATFORM, 1070, 500], [platforms.STD_PLATFORM, 1140, 500], [platforms.STD_PLATFORM, 1120, 280], [platforms.STD_PLATFORM, 1190, 280], [platforms.STD_PLATFORM, 1260, 280], ] # Go through the array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.STD_PLATFORM) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player, buho, enemigo): # Call the parent constructor Level.__init__(self, player, buho, enemigo) self.background = pygame.image.load("background_01.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -2500 # Aqui tenemos las plataformas del background level = [ [platforms.GRASS_LEFT, 500, 500], [platforms.GRASS_MIDDLE, 570, 500], [platforms.GRASS_RIGHT, 640, 500], [platforms.GRASS_LEFT, 800, 400], [platforms.GRASS_MIDDLE, 870, 400], [platforms.GRASS_RIGHT, 940, 400], [platforms.GRASS_LEFT, 1000, 500], [platforms.GRASS_MIDDLE, 1070, 500], [platforms.GRASS_RIGHT, 1140, 500], [platforms.STONE_PLATFORM_LEFT, 1120, 280], [platforms.STONE_PLATFORM_MIDDLE, 1190, 280], [platforms.STONE_PLATFORM_RIGHT, 1260, 280], ] for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player block.buho = self.buho block.enemigo = self.enemigo self.platform_list.add(block) # Se agrega el bloque pequeño que se mueve block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player, buho, enemigo): Level.__init__(self, player, buho, enemigo) self.background = pygame.image.load("background_02.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -1000 # Array with type of platform, and x, y location of the platform. level = [ [platforms.STONE_PLATFORM_LEFT, 500, 550], [platforms.STONE_PLATFORM_MIDDLE, 570, 550], [platforms.STONE_PLATFORM_RIGHT, 640, 550], [platforms.GRASS_LEFT, 800, 400], [platforms.GRASS_MIDDLE, 870, 400], [platforms.GRASS_RIGHT, 940, 400], [platforms.GRASS_LEFT, 1000, 500], [platforms.GRASS_MIDDLE, 1070, 500], [platforms.GRASS_RIGHT, 1140, 500], [platforms.STONE_PLATFORM_LEFT, 1120, 280], [platforms.STONE_PLATFORM_MIDDLE, 1190, 280], [platforms.STONE_PLATFORM_RIGHT, 1260, 280], ] for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player block.buho = self.buho block.enemigo = self.enemigo self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1500 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player, enemy): Level.__init__(self, player, enemy) self.background = pygame.image.load("images/background.png").convert() self.background = pygame.transform.scale2x(self.background) self.background.set_colorkey(constants.WHITE) self.level_limit = -1000 level = [ [platforms.STONE_PLATFORM_LEFT, 500, 550], [platforms.STONE_PLATFORM_MIDDLE, 570, 550], [platforms.STONE_PLATFORM_RIGHT, 640, 550], [platforms.GRASS_LEFT, 800, 400], [platforms.GRASS_MIDDLE, 870, 400], [platforms.GRASS_RIGHT, 940, 400], [platforms.GRASS_LEFT, 1000, 500], [platforms.GRASS_MIDDLE, 1070, 500], [platforms.GRASS_RIGHT, 1140, 500], [platforms.STONE_PLATFORM_LEFT, 1120, 280], [platforms.STONE_PLATFORM_MIDDLE, 1190, 280], [platforms.STONE_PLATFORM_RIGHT, 1260, 280], ] for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1500 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): Level.__init__(self, player) self.background = pygame.image.load('background_02.png').convert() self.background.set_colorkey(constants.white) self.level_limit = -1000 level = [ [platforms.BUBBLES, 500, 500], [platforms.BUBBLES, 570, 550], [platforms.BUBBLES, 640, 550], [platforms.BUBBLES, 800, 400], [platforms.BUBBLES, 870, 400], [platforms.BUBBLES, 940, 400], [platforms.BUBBLES, 1000, 500], [platforms.BUBBLES, 1070, 500], [platforms.BUBBLES, 1140, 500], [platforms.YELLOW_BRICK, 1120, 280], [platforms.YELLOW_BRICK, 1190, 280], [platforms.YELLOW_BRICK, 1260, 280], ] for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # moving block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1500 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block)
def createLevel(self): self.background = pygame.image.load(BACKGROUND_02).convert() self.background.set_colorkey(WHITE) self.level_limit = -1500 # Array with type of platform, and x, y location of the platform. self.level = [[platforms.GRASS_LEFT, 0, 500]] for i in range(1, 20): self.level.append([platforms.GRASS_MIDDLE, 20 + 70 * i, 500]) self.level.append([platforms.GRASS_RIGHT, 1400, 500]) self.level.append([platforms.GRASS_MIDDLE, 1600, 500]) self.add_platform() # Add a custom moving platform block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1600 block.rect.y = 500 block.boundary_left = 1500 block.boundary_right = 2500 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): Level.__init__(self, player) self.background = pygame.image.load("background_01.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -2500 level = [ [platforms.GRASS_LEFT, 500, 500], [platforms.GRASS_MIDDLE, 5700, 500], [platforms.GRASS_RIGHT, 640, 500], [platforms.GRASS_LEFT, 800, 400], [platforms.GRASS_MIDDLE, 870, 400], [platforms.GRASS_RIGHT, 940, 400], [platforms.GRASS_LEFT, 1000, 500], [platforms.GRASS_MIDDLE, 1070, 500], [platforms.GRASS_RIGHT, 1140, 500], [platforms.STONE_PLATFORM_LEFT, 1120, 280], [platforms.STONE_PLATFORM_MIDDLE, 1190, 280], [platforms.STONE_PLATFORM_RIGHT, 1260, 280], ] for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): Level.__init__(self, player) self.level_limit = -1 * constants.SCREEN_WIDTH self.background = pygame.transform.scale( pygame.image.load('images/background/Background.png'), (abs(self.level_limit), constants.SCREEN_HEIGHT)) self.background.set_colorkey(constants.WHITE) # Array with type of platform, and x, y location of the platform. level = [ #Top left Platforms [platforms.STONE_CLIFF_RIGHT, 480, 280], #Middle Platform [platforms.GRASS_CLIFF_LEFT, 940, 500], [platforms.GRASS_CLIFF_RIGHT, 1400, 500], #Solo Platform [platforms.FLOATING_STONE, 700, 450] #Top Right Platform # [platforms.GRASS_FLOOR_THICK, 0, 730] # [platforms.ROPE, x, y] ] #Bottom for x in range(0, constants.SCREEN_WIDTH, 32): level.append([platforms.GRASS_FLOOR_GRASSY, x, 730]) #Top Left Platforms for x in range(0, 240, 16): level.append([platforms.STONE_CLIFF_MIDDLE, x, 200]) for x in range(240, 400, 16): level.append([platforms.STONE_CLIFF_MIDDLE, x, 240]) for x in range(0, 480, 16): level.append([platforms.STONE_CLIFF_MIDDLE, x, 280]) for x in range(0, 400, 16): level.append([platforms.STONE_CLIFF_FILL, x, 260]) #Middle Platform for y in range(602, constants.SCREEN_HEIGHT, 78): level.append([platforms.GRASS_CLIFF_LEFT_FILL, 940, y]) for y in range(586, constants.SCREEN_HEIGHT, 60): level.append([platforms.GRASS_CLIFF_RIGHT_FILL, 1400, y]) for x in range(1028, 1400, 28): level.append([platforms.GRASS_FLOOR_SKINNY, x, 500]) for x in range(940 + 31, 1400, 16): for y in range(500 + 102, constants.SCREEN_HEIGHT, 48): level.append([platforms.STONE_CLIFF_FILL, x, y]) for x in range(940 + 88, 1400, 16): level.append([platforms.STONE_CLIFF_FILL, x, 522]) level.append([platforms.STONE_CLIFF_FILL, x, 560]) #Top Right Platforms for x in range(2000, 2480, 48): level.append([platforms.STONE_PLATFORM_LONG, x, 230]) for x in range(1800, constants.SCREEN_WIDTH, 48): level.append([platforms.STONE_PLATFORM_LONG, x, 400]) #Left and Right Map Boundary for y in range(0, constants.SCREEN_HEIGHT, 48): level.append([platforms.STONE_CLIFF_FILL, -16, y]) level.append( [platforms.STONE_CLIFF_FILL, constants.SCREEN_WIDTH + 16, y]) # Go through the array and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) #Ropes # ============================================================================= # level_rope = [] # for y in range (280, 700, 23): # level_rope.append([platforms.ROPE, 550, y]) # # for string in level_rope: # rope = platforms.Rope(string[0]) # rope.rect.x = string[1] # rope.rect.y = string[2] # rope.player = self.player # self.rope_list.add(rope) # ============================================================================= level_bound = [] level_bound.append([platforms.INVISIBLE_BLOCK, 240, 155]) level_bound.append([platforms.INVISIBLE_BLOCK, 400, 195]) level_bound.append([platforms.INVISIBLE_BLOCK, 540, 235]) level_bound.append([platforms.INVISIBLE_BLOCK, 850, 720]) level_bound.append([platforms.INVISIBLE_BLOCK, 1520, 720]) level_bound.append([platforms.INVISIBLE_BLOCK, 1790, 370]) level_bound.append([platforms.INVISIBLE_BLOCK, 1985, 200]) level_bound.append([platforms.INVISIBLE_BLOCK, 2475, 200]) for brick in level_bound: bound = platforms.Rope(brick[0]) bound.rect.x = brick[1] bound.rect.y = brick[2] self.bound_list.add(bound) #Add a custom moving platform #Left Floating Platform block = platforms.MovingPlatform(platforms.FLOATING_STONE) block.rect.x = 550 block.rect.y = 330 block.boundary_top = 330 block.boundary_bottom = 665 block.change_y = 1 block.player = self.player block.level = self self.platform_list.add(block) #Middle Left Floating Platform block = platforms.MovingPlatform(platforms.FLOATING_GRASS) block.rect.x = 860 block.rect.y = 500 block.boundary_top = 500 block.boundary_bottom = 665 block.change_y = 1 block.player = self.player block.level = self self.platform_list.add(block) #Middle Right Floating Platform block = platforms.MovingPlatform(platforms.FLOATING_GRASS) block.rect.x = 1460 block.rect.y = 500 block.boundary_top = 500 block.boundary_bottom = 665 block.change_y = 1 block.player = self.player block.level = self self.platform_list.add(block) #Right Floating Platform block = platforms.MovingPlatform(platforms.FLOATING_STONE) block.rect.x = 1750 block.rect.y = 450 block.boundary_top = 450 block.boundary_bottom = 665 block.change_y = 1 block.player = self.player block.level = self self.platform_list.add(block) # ============================================================================= # #Top Right Left Floating Platform # block = platforms.MovingPlatform(platforms.FLOATING_STONE) # block.rect.x = 1950 # block.rect.y = 200 # block.boundary_top = 200 # block.boundary_bottom = 350 # block.change_y = 1 # block.player = self.player # block.level = self # self.platform_list.add(block) # ============================================================================= # Test Enemies """ Enemies for Demonstration""" # ============================================================================= # enemy = Enemyspotted.Enemy_Bandit(400, 650, 240, 400) # enemy.player = self.player # enemy.level = self # self.enemy_list.add(enemy) # ============================================================================= # ============================================================================= # enemy = Enemyspotted.Enemy_Blob(400, 650, 240, 400) # enemy.player = self.player # enemy.level = self # self.enemy_list.add(enemy) # ============================================================================= # ============================================================================= # enemy = Enemyspotted.Enemy_Midget(400, 650, 240, 400) # enemy.player = self.player # enemy.level = self # self.enemy_list.add(enemy) # ============================================================================= """ Enemies for Game """ #Spawn Enemies Platform_Areas_Bottom = [] Platform_Areas_Top_Left = [] Platform_Areas_Top_Right = [] Bottom_Left_Area = [[ 0, 845 ], 650, 4] #[x bounds], [y location], [number of max type of enemies] Top_Left_Area_1 = [[0, 240], 160, 1] Top_Left_Area_2 = [[240, 400], 200, 1] Top_Left_Area_3 = [[400, 480], 240, 1] Bottom_Right_Area = [[1530, constants.SCREEN_WIDTH], 650, 4] Right_Middle_Area = [[1800, constants.SCREEN_WIDTH], 370, 4] Right_Top_Area = [[2000, 2480], 190, 3] Platform_Areas_Bottom.append(Bottom_Left_Area) Platform_Areas_Bottom.append(Bottom_Right_Area) Platform_Areas_Top_Left.append(Top_Left_Area_1) Platform_Areas_Top_Left.append(Top_Left_Area_2) Platform_Areas_Top_Left.append(Top_Left_Area_3) Platform_Areas_Top_Right.append(Right_Middle_Area) Platform_Areas_Top_Right.append(Right_Top_Area) for area in Platform_Areas_Bottom: for _ in range(area[2]): x = random.randint(area[0][0], area[0][1]) y = area[1] left_bound = area[0][0] right_bound = area[0][1] enemy = Enemyspotted.Enemy_Bandit(x, y, left_bound, right_bound) enemy.player = self.player enemy.level = self self.enemy_list.add(enemy) for area in Platform_Areas_Top_Left: for _ in range(area[2]): x = random.randint(area[0][0], area[0][1]) y = area[1] left_bound = area[0][0] right_bound = area[0][1] enemy = Enemyspotted.Enemy_Blob(x, y, left_bound, right_bound) enemy.player = self.player enemy.level = self self.enemy_list.add(enemy) for area in Platform_Areas_Top_Right: for _ in range(area[2]): x = random.randint(area[0][0], area[0][1]) y = area[1] left_bound = area[0][0] right_bound = area[0][1] enemy = Enemyspotted.Enemy_Midget(x, y, left_bound, right_bound) enemy.player = self.player enemy.level = self self.enemy_list.add(enemy)
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.background = utils.load_png_bg("BG.png") self.background.set_colorkey(constants.WHITE) self.level_limit = -2000 self.next_city = 0 self.preced_city = 0 # Array with type of platform, and x, y location of the platform. level_surroungings, level_platforms = utils.load_level("level01") # Go through the array above and add platforms for platform in level_platforms: block = platforms.Platform(platforms.plat_dict[platform[0]]) block.rect.x = int(platform[1]) block.rect.y = int(platform[2]) self.platform_list.add(block) for surrounding in level_surroungings: block = platforms.Platform(platforms.plat_dict.get(surrounding[0])) block.rect.x = int(surrounding[1]) block.rect.y = int(surrounding[2]) self.surroundings_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform( platforms.plat_dict["X128_PLATFORM_GRASS_LEFT"]) block.rect.x = 2100 block.rect.y = 280 block.boundary_left = 2100 block.boundary_right = 2400 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform( platforms.plat_dict["X128_PLATFORM_GRASS_MIDDLE"]) block.rect.x = 2228 block.rect.y = 280 block.boundary_left = 2228 block.boundary_right = 2528 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform( platforms.plat_dict["X128_PLATFORM_GRASS_RIGHT"]) block.rect.x = 2356 block.rect.y = 280 block.boundary_left = 2356 block.boundary_right = 2656 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): #Calling the parent constructor. Level.__init__(self, player) #I load up my background image in the below line. self.background = pygame.image.load("Aleppo_One.png").convert() #This line sets a transparent color for the background. self.background.set_colorkey(constants.WHITE) self.level_limit = -500 # Adding moving platforms for the player. There are quite a lot #added here which I did soley to get a better understanding of how #to add these platforms #Platform 1 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_LEFT) block.rect.x = 300 block.rect.y = 300 block.boundary_top = 200 block.boundary_bottom = 400 block.change_y = -8 block.player = self.player block.level = self self.platform_list.add(block) #Platform 2 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 500 block.rect.y = 500 block.boundary_top = 400 block.boundary_bottom = 650 block.change_y = -5 block.player = self.player block.level = self self.platform_list.add(block) #Platform 3 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 600 block.rect.y = 600 block.boundary_top = 500 block.boundary_bottom = 700 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) #Platform 4 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_LEFT) block.rect.x = 900 block.rect.y = 700 block.boundary_top = 300 block.boundary_bottom = 800 block.change_y = -3 block.player = self.player block.level = self self.platform_list.add(block) #Platform 5 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1400 block.rect.y = 700 block.boundary_top = 300 block.boundary_bottom = 800 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) #Platform 6 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 1700 block.rect.y = 700 block.boundary_top = 300 block.boundary_bottom = 800 block.change_y = -6 block.player = self.player block.level = self self.platform_list.add(block) #Platform 7 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 2300 block.rect.y = 700 block.boundary_top = 200 block.boundary_bottom = 800 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) #Platform 8 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2800 block.rect.y = 600 block.boundary_top = 300 block.boundary_bottom = 800 block.change_y = -8 block.player = self.player block.level = self self.platform_list.add(block) #Platform 9 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 3000 block.rect.y = 600 block.boundary_top = 300 block.boundary_bottom = 800 block.change_y = -5 block.player = self.player block.level = self self.platform_list.add(block) #Platform 10 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 3400 block.rect.y = 600 block.boundary_top = 300 block.boundary_bottom = 800 block.change_y = -5 block.player = self.player block.level = self self.platform_list.add(block) #These platforms prevent the user from going to far to the right. block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 4200 block.rect.y = 550 block.boundary_top = 550 block.boundary_bottom = 600 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 4200 block.rect.y = 500 block.boundary_top = 500 block.boundary_bottom = 550 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 4200 block.rect.y = 450 block.boundary_top = 450 block.boundary_bottom = 500 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 4200 block.rect.y = 400 block.boundary_top = 400 block.boundary_bottom = 450 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 4200 block.rect.y = 350 block.boundary_top = 350 block.boundary_bottom = 400 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) #These platforms prevent the user from going to far to the Left. block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = -50 block.rect.y = 550 block.boundary_top = 550 block.boundary_bottom = 600 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = -50 block.rect.y = 500 block.boundary_top = 500 block.boundary_bottom = 550 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = -50 block.rect.y = 450 block.boundary_top = 450 block.boundary_bottom = 500 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = -50 block.rect.y = 400 block.boundary_top = 400 block.boundary_bottom = 450 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = -50 block.rect.y = 350 block.boundary_top = 350 block.boundary_bottom = 400 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) #These platforms form a wall that the player must get through to progress #Wall 1 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 800 block.rect.y = 550 block.boundary_top = 550 block.boundary_bottom = 600 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 800 block.rect.y = 500 block.boundary_top = 500 block.boundary_bottom = 550 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 800 block.rect.y = 450 block.boundary_top = 450 block.boundary_bottom = 500 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 800 block.rect.y = 400 block.boundary_top = 400 block.boundary_bottom = 450 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 800 block.rect.y = 350 block.boundary_top = 350 block.boundary_bottom = 400 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) #These platforms form a wall that the player must get through to progress #Wall 2 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 1200 block.rect.y = 550 block.boundary_top = 550 block.boundary_bottom = 600 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 1200 block.rect.y = 500 block.boundary_top = 500 block.boundary_bottom = 550 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 1200 block.rect.y = 450 block.boundary_top = 450 block.boundary_bottom = 500 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 1200 block.rect.y = 400 block.boundary_top = 400 block.boundary_bottom = 450 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 1200 block.rect.y = 350 block.boundary_top = 350 block.boundary_bottom = 400 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) #These platforms form a wall that the player must get through to progress #Wall 3 block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2000 block.rect.y = 550 block.boundary_top = 550 block.boundary_bottom = 600 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2000 block.rect.y = 500 block.boundary_top = 500 block.boundary_bottom = 550 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2000 block.rect.y = 450 block.boundary_top = 450 block.boundary_bottom = 500 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2000 block.rect.y = 400 block.boundary_top = 400 block.boundary_bottom = 450 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2000 block.rect.y = 350 block.boundary_top = 350 block.boundary_bottom = 400 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) #These platforms form a wall that the player must get through to progress block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 3200 block.rect.y = 550 block.boundary_top = 550 block.boundary_bottom = 600 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 3200 block.rect.y = 500 block.boundary_top = 500 block.boundary_bottom = 550 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 3200 block.rect.y = 450 block.boundary_top = 450 block.boundary_bottom = 500 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 3200 block.rect.y = 400 block.boundary_top = 400 block.boundary_bottom = 450 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 3200 block.rect.y = 350 block.boundary_top = 350 block.boundary_bottom = 400 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 3200 block.rect.y = 250 block.boundary_top = 250 block.boundary_bottom = 350 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 3200 block.rect.y = 200 block.boundary_top = 200 block.boundary_bottom = 250 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) #These platforms form a wall that the player must get through to progress block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2500 block.rect.y = 550 block.boundary_top = 550 block.boundary_bottom = 600 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2500 block.rect.y = 500 block.boundary_top = 500 block.boundary_bottom = 550 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2500 block.rect.y = 450 block.boundary_top = 450 block.boundary_bottom = 500 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2500 block.rect.y = 400 block.boundary_top = 400 block.boundary_bottom = 450 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2500 block.rect.y = 350 block.boundary_top = 350 block.boundary_bottom = 400 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2500 block.rect.y = 250 block.boundary_top = 250 block.boundary_bottom = 350 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_RIGHT) block.rect.x = 2500 block.rect.y = 200 block.boundary_top = 200 block.boundary_bottom = 250 block.change_y = 0 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 3. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load( "Assets/Levels/Snow/BG/Snow.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -6000 # Array with type of platform, and x, y location of the platform. platform_array = [ [constants.SNOW_STONE_PLATFORM_FLAT, -450, 575], [constants.SNOW_GRASS_LEFT, 630, 425], [constants.SNOW_GRASS_MIDDLE, 700, 425], [constants.SNOW_GRASS_MIDDLE, 770, 425], [constants.SNOW_GRASS_RIGHT, 840, 425], [constants.SNOW_GRASS_LEFT, 1200, 200], [constants.SNOW_GRASS_MIDDLE, 1270, 200], [constants.SNOW_GRASS_MIDDLE, 1340, 200], [constants.SNOW_GRASS_RIGHT, 1410, 200], [constants.SNOW_GRASS_LEFT, 2200, 425], [constants.SNOW_GRASS_MIDDLE, 2270, 425], [constants.SNOW_GRASS_MIDDLE, 2340, 425], [constants.SNOW_GRASS_MIDDLE, 2410, 425], [constants.SNOW_GRASS_RIGHT, 2480, 425], [constants.SNOW_GRASS_LEFT, 2610, 350], [constants.SNOW_GRASS_MIDDLE, 2680, 350], [constants.SNOW_GRASS_MIDDLE, 2750, 350], [constants.SNOW_GRASS_MIDDLE, 2820, 350], [constants.SNOW_GRASS_RIGHT, 2890, 350], [constants.SNOW_GRASS_LEFT, 3010, 250], [constants.SNOW_GRASS_MIDDLE, 3080, 250], [constants.SNOW_GRASS_MIDDLE, 3150, 250], [constants.SNOW_GRASS_MIDDLE, 3220, 250], [constants.SNOW_GRASS_RIGHT, 3290, 250], [constants.SNOW_GRASS_LEFT, 5000, 425], [constants.SNOW_GRASS_MIDDLE, 5070, 425], [constants.SNOW_GRASS_MIDDLE, 5140, 425], [constants.SNOW_GRASS_RIGHT, 5210, 425], [constants.SNOW_GRASS_LEFT, 5400, 350], [constants.SNOW_GRASS_MIDDLE, 5470, 350], [constants.SNOW_GRASS_MIDDLE, 5540, 350], [constants.SNOW_GRASS_RIGHT, 5610, 350], # 5700 [constants.SNOW_GRASS_LEFT, 5770, 350], [constants.SNOW_GRASS_MIDDLE, 5840, 350], [constants.SNOW_GRASS_MIDDLE, 5910, 350], [constants.SNOW_GRASS_MIDDLE, 5980, 350], [constants.SNOW_GRASS_RIGHT, 6050, 350], ### [constants.SNOW_GRASS_LEFT, 6220, 220], [constants.SNOW_GRASS_MIDDLE, 6290, 220], [constants.SNOW_GRASS_MIDDLE, 6360, 220], [constants.SNOW_GRASS_MIDDLE, 6430, 220], [constants.SNOW_GRASS_RIGHT, 6500, 220], ] # Go through the array above and add platforms for platform in platform_array: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Array with type of enemy, and x, and patrol distance of the enemy. enemy_array = [ [enemies.SNOW_ENEMY, 2610, 435, 245], [enemies.SNOW_ENEMY, 3110, 435, 245], [enemies.SNOW_ENEMY, 5000, 435, 245], ] # Go through the array above and add enemies for enemy in enemy_array: enem = enemies.Enemy(enemy[0], enemy[3]) enem.rect.x = enemy[1] enem.rect.y = enemy[2] enem.player = self.player self.enemy_list.add(enem) # Array with type x and y of good object. good_object_array = [ [constants.NUT, 480, 345], [constants.NUT, 750, 250], [constants.NUT, 950, 80], [constants.NUT, 1500, 80], [constants.NUT, 1800, 320], [constants.NUT, 1910, 320], [constants.NUT, 1980, 320], [constants.NUT, 2670, 230], [constants.NUT, 3080, 170], [constants.NUT, 4180, 320], [constants.NUT, 4450, 400], [constants.NUT, 4690, 320], [constants.NUT, 6200, 80], [constants.NUT, 6250, 80], [constants.NUT, 6300, 80], ] # Array with type x and y of bad object. bad_object_array = [ [constants.SNOW_CRYSTAL, 1550, 540], [constants.SNOW_CRYSTAL, 1580, 540], [constants.SNOW_CRYSTAL, 1620, 540], [constants.SNOW_CRYSTAL, 3400, 540], [constants.SNOW_CRYSTAL, 3430, 540], [constants.SNOW_CRYSTAL, 4050, 540], [constants.SNOW_CRYSTAL, 4080, 540], [constants.SNOW_CRYSTAL, 4550, 540], [constants.SNOW_CRYSTAL, 4590, 540], ] # Array with type x and y of standard object. standard_object_array = [ [constants.SNOW_TREE_2, 400, 400], [constants.SNOW_SNOWMAN, 100, 470], [constants.SNOW_TREE_1, 1240, 280], [constants.SNOW_TREE_2, 1700, 400], [constants.SNOW_SIGN, 2340, 365], [constants.SNOW_IGLOO, 2670, 300], [constants.SNOW_TREE_2, 2800, 400], [constants.SNOW_TREE_2, 2900, 400], [constants.SNOW_SNOWMAN, 3590, 470], [constants.SNOW_TREE_2, 3850, 400], [constants.SNOW_TREE_1, 3750, 280], [constants.SNOW_TREE_2, 4300, 400], [constants.SNOW_TREE_1, 4340, 280], [constants.SNOW_TREE_2, 4480, 400], [constants.SNOW_TREE_2, 4700, 400], [constants.SNOW_TREE_2, 4800, 400], [constants.SNOW_TREE_2, 5800, 400], [constants.SNOW_SNOWMAN, 6000, 470], [constants.SNOW_TREE_1, 6200, 280], [constants.SNOW_ICEBOX, 6550, 500], [constants.SNOW_SIGNARROW, 6700, 470], [constants.SNOW_TREE_1, 6900, 280], [constants.SNOW_TREE_1, 7100, 280], [constants.SNOW_TREE_1, 7300, 280], [constants.SNOW_TREE_1, 7500, 280], [constants.SNOW_TREE_1, 7800, 280], ] # Go through the array above and add good object for good_object in good_object_array: obj = objects.Object(good_object[0]) obj.rect.x = good_object[1] obj.rect.y = good_object[2] obj.player = self.player self.good_object_list.add(obj) # Go through the array above and add bad object for bad_object in bad_object_array: obj = objects.Object(bad_object[0]) obj.rect.x = bad_object[1] obj.rect.y = bad_object[2] obj.player = self.player self.bad_object_list.add(obj) # Go through the array above and add standard object for standard_object in standard_object_array: obj = objects.Object(standard_object[0]) obj.rect.x = standard_object[1] obj.rect.y = standard_object[2] obj.player = self.player self.standard_object_list.add(obj) # Add a custom moving platform block = platforms.MovingPlatform( constants.SNOW_STONE_PLATFORM_TOP_MIDDLE) block.rect.x = 1000 block.rect.y = 400 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load( "Assets/Levels/Jungle/Bg/Jungle.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -6000 # Array with type of platform, and x, y location of the platform. platform_array = [ [constants.JUNGLE_STONE_PLATFORM_FLAT, -450, 575], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 200, 430], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 280, 430], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 480, 310], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 560, 310], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 760, 430], [constants.JUNGLE_STONE_PLATFORM_TOP_MIDDLE, 840, 430], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_1, 1500, 540], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_1, 2270, 540], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_2, 1600, 440], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 2800, 450], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 2870, 450], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 3020, 350], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 3090, 350], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 3160, 350], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 3310, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 3380, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 3450, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 3520, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 3800, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 3870, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 4150, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 4220, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 4290, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 4360, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 4640, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 4710, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 4990, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 5060, 250], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 5130, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 5200, 250], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 5350, 350], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 5420, 350], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 5490, 350], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 5640, 450], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 5710, 450], [constants.JUNGLE_STONE_PLATFORM_TOP_LEFT_3, 6600, 430], [constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_3, 6670, 430], [constants.JUNGLE_STONE_PLATFORM_TOP_RIGHT_3, 6740, 430], ] # Go through the array above and add platforms for platform in platform_array: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Array with type of enemy, and x, and distance of the enemy. enemy_array = [ [enemies.JUNGLE_ENEMY, 600, 310, 120], [enemies.JUNGLE_ENEMY, 1060, 435, 200], [enemies.JUNGLE_ENEMY, 3020, 450, 500], [enemies.JUNGLE_ENEMY, 4220, 400, 400], [enemies.JUNGLE_ENEMY, 5060, 400, 400], ] # Go through the array above and add enemies for enemy in enemy_array: enem = enemies.Enemy(enemy[0], enemy[3]) enem.rect.x = enemy[1] enem.rect.y = enemy[2] enem.player = self.player self.enemy_list.add(enem) # Array with type x and y of good object. good_object_array = [ [constants.BLACKBERRY, 520, 80], [constants.BLACKBERRY, 530, 80], [constants.BLACKBERRY, 1150, 280], [constants.BLACKBERRY, 1170, 280], [constants.BLACKBERRY, 1800, 280], [constants.BLACKBERRY, 1810, 290], [constants.BLACKBERRY, 1820, 280], [constants.BLACKBERRY, 1900, 280], [constants.BLACKBERRY, 1910, 290], [constants.BLACKBERRY, 1920, 280], [constants.BLACKBERRY, 2000, 280], [constants.BLACKBERRY, 2010, 290], [constants.BLACKBERRY, 2020, 280], [constants.JUNGLE_MUSHROOM_1, 3100, 320], [constants.JUNGLE_MUSHROOM_1, 3130, 320], [constants.JUNGLE_MUSHROOM_1, 3160, 320], [constants.BLACKBERRY, 3655, 30], [constants.BLACKBERRY, 3665, 40], [constants.BLACKBERRY, 4005, 30], [constants.BLACKBERRY, 4015, 40], [constants.BLACKBERRY, 4495, 30], [constants.BLACKBERRY, 4505, 40], [constants.BLACKBERRY, 4845, 30], [constants.BLACKBERRY, 4855, 40], [constants.JUNGLE_MUSHROOM_1, 3830, 220], [constants.JUNGLE_MUSHROOM_1, 5060, 220], [constants.JUNGLE_MUSHROOM_1, 5090, 220], [constants.JUNGLE_MUSHROOM_1, 5110, 220], [constants.BLACKBERRY, 6915, 210], [constants.BLACKBERRY, 6925, 200], [constants.BLACKBERRY, 6935, 210], [constants.BLACKBERRY, 6945, 200], [constants.BLACKBERRY, 6955, 210], [constants.JUNGLE_MUSHROOM_1, 6670, 540], [constants.JUNGLE_MUSHROOM_1, 6720, 540], [constants.JUNGLE_MUSHROOM_1, 6770, 540], ] # Go through the array above and add good object for good_object in good_object_array: obj = objects.Object(good_object[0]) obj.rect.x = good_object[1] obj.rect.y = good_object[2] obj.player = self.player self.good_object_list.add(obj) # Array with type x and y of bad object. bad_object_array = [ [constants.JUNGLE_STONE_PLATFORM_WAVES, 1570, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1570, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1640, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1640, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1710, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1710, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1780, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1780, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1850, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1850, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1920, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1920, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 1990, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 1990, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 2060, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 2060, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 2130, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 2130, 570], [constants.JUNGLE_STONE_PLATFORM_WAVES, 2200, 540], [constants.JUNGLE_STONE_PLATFORM_WATER, 2200, 570], ] # Go through the array above and add bad object for bad_object in bad_object_array: obj = objects.Object(bad_object[0]) obj.rect.x = bad_object[1] obj.rect.y = bad_object[2] obj.player = self.player self.bad_object_list.add(obj) # Array with type x and y of standard object. standard_object_array = [ [constants.JUNGLE_MUSHROOM_2, 770, 400], [constants.JUNGLE_SIGN_2, 20, 500], [constants.JUNGLE_BUSH_1, 220, 390], [constants.JUNGLE_CRATE, 420, 490], [constants.JUNGLE_STONE, 480, 530], [constants.JUNGLE_BUSH_3, 540, 540], [constants.JUNGLE_BUSH_3, 570, 540], [constants.JUNGLE_BUSH_3, 600, 540], [constants.JUNGLE_TREE_1, 1000, 540], [constants.JUNGLE_TREE_1, 1200, 540], [constants.JUNGLE_TREE_1, 1400, 540], [constants.JUNGLE_SIGN_1, 1510, 490], [constants.JUNGLE_STONE, 2400, 530], [constants.JUNGLE_TREE_3, 2410, 270], [constants.JUNGLE_BUSH_2, 2820, 410], [constants.JUNGLE_STONE, 3300, 530], [constants.JUNGLE_BUSH_2, 3340, 530], [constants.JUNGLE_STONE, 3380, 530], [constants.JUNGLE_TREE_2, 3400, 270], [constants.JUNGLE_TREE_1, 5460, 320], [constants.JUNGLE_STONE, 5660, 410], [constants.JUNGLE_BUSH_3, 5680, 420], [constants.JUNGLE_TREE_3, 6050, 270], [constants.JUNGLE_TREE_3, 6100, 270], [constants.JUNGLE_TREE_3, 6150, 270], [constants.JUNGLE_BUSH_2, 6050, 530], [constants.JUNGLE_STONE, 6100, 530], [constants.JUNGLE_BUSH_2, 6150, 530], [constants.JUNGLE_BUSH_1, 6670, 390], [constants.JUNGLE_STONE, 6690, 390], [constants.JUNGLE_BUSH_2, 6870, 530], [constants.JUNGLE_STONE, 6880, 530], [constants.JUNGLE_STONE, 6920, 530], [constants.JUNGLE_SIGN_2, 6960, 490], [constants.JUNGLE_MUSHROOM_2, 3400, 220], [constants.JUNGLE_MUSHROOM_2, 3430, 220], [constants.JUNGLE_MUSHROOM_2, 3430, 220], [constants.JUNGLE_MUSHROOM_2, 4220, 220], [constants.JUNGLE_MUSHROOM_2, 4250, 220], [constants.JUNGLE_MUSHROOM_2, 5410, 320], ] # Go through the array above and add standard object for standard_object in standard_object_array: obj = objects.Object(standard_object[0]) obj.rect.x = standard_object[1] obj.rect.y = standard_object[2] obj.player = self.player self.standard_object_list.add(obj) # Add a custom moving platform block_1 = platforms.MovingPlatform( constants.JUNGLE_STONE_PLATFORM_BOTTOM_MIDDLE_2_1) block_1.rect.x = 1950 block_1.rect.y = 440 block_1.boundary_left = 1900 block_1.boundary_right = 2100 block_1.change_x = -1 block_1.player = self.player block_1.level = self self.platform_list.add(block_1) block_2 = platforms.MovingPlatform(constants.JUNGLE_CRATE) block_2.rect.x = 3655 block_2.rect.y = 200 block_2.boundary_top = 30 block_2.boundary_bottom = 560 block_2.change_y = 2 block_2.player = self.player block_2.level = self self.platform_list.add(block_2) block_3 = platforms.MovingPlatform(constants.JUNGLE_CRATE) block_3.rect.x = 4005 block_3.rect.y = 400 block_3.boundary_top = 30 block_3.boundary_bottom = 560 block_3.change_y = 2 block_3.player = self.player block_3.level = self self.platform_list.add(block_3) block_4 = platforms.MovingPlatform(constants.JUNGLE_CRATE) block_4.rect.x = 4495 block_4.rect.y = 200 block_4.boundary_top = 30 block_4.boundary_bottom = 560 block_4.change_y = 2 block_4.player = self.player block_4.level = self self.platform_list.add(block_4) block_5 = platforms.MovingPlatform(constants.JUNGLE_CRATE) block_5.rect.x = 4845 block_5.rect.y = 400 block_5.boundary_top = 30 block_5.boundary_bottom = 560 block_5.change_y = 2 block_5.player = self.player block_5.level = self self.platform_list.add(block_5)
def __init__(self, player): """ Create level 2. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load("Land.jpg").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -3000 # Array with type of platform, and x, y location of the platform. level = [[platforms.GRASS_LEFT, 500, 550], [platforms.GRASS_MIDDLE, 570, 550], [platforms.GRASS_RIGHT, 640, 550], [platforms.GRASS_LEFT, 820, 400], [platforms.GRASS_MIDDLE, 890, 400], [platforms.GRASS_RIGHT, 960, 400], [platforms.GRASS_LEFT, 1060, 500], [platforms.GRASS_MIDDLE, 1130, 500], [platforms.GRASS_RIGHT, 1200, 500], [platforms.GRASS_LEFT, 1170, 280], [platforms.GRASS_MIDDLE, 1240, 280], [platforms.GRASS_RIGHT, 1310, 280], ] # Go through the array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add moving platforms block = platforms.MovingPlatform(platforms.GRASS_MIDDLE) block.rect.x = 1700 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 470 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.GRASS_MIDDLE) block.rect.x = 2000 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 450 block.change_y = -2 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.GRASS_MIDDLE) block.rect.x = 2300 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 450 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) # Add main enemy sprite = enemies.Enemy(enemies.MAIN_ENEMY) sprite.rect.x = 10 sprite.boundary_left = 0 sprite.boundary_right = -1000 sprite.change_x = 1.5 sprite.rect.y = 10 sprite.boundary_top = 0 sprite.boundary_bottom = 550 sprite.change_y = 1.5 sprite.player = self.player sprite.level = self sprite.main_enemy = True self.enemy_list.add(sprite) # Add regular enemies sprite = enemies.Enemy(enemies.BUG) sprite.rect.x = 1500 sprite.boundary_left = 1350 sprite.boundary_right = 1600 sprite.boundary_top = 0 sprite.boundary_bottom = 600 sprite.change_x = -1 sprite.rect.y = 566 sprite.player = self.player sprite.level = self self.enemy_list.add(sprite) sprite = enemies.Enemy(enemies.BUG) sprite.rect.x = 1700 sprite.boundary_left = 1550 sprite.boundary_right = 1800 sprite.boundary_top = 0 sprite.boundary_bottom = 600 sprite.change_x = -2 sprite.rect.y = 566 sprite.player = self.player sprite.level = self self.enemy_list.add(sprite) sprite = enemies.Enemy(enemies.BUG) sprite.rect.x = 2100 sprite.boundary_left = 1950 sprite.boundary_right = 2200 sprite.boundary_top = 0 sprite.boundary_bottom = 600 sprite.change_x = -1 sprite.rect.y = 566 sprite.player = self.player sprite.level = self self.enemy_list.add(sprite) sprite = enemies.Enemy(enemies.BUG) sprite.rect.x = 1500 sprite.boundary_left = 1350 sprite.boundary_right = 1600 sprite.boundary_top = 0 sprite.boundary_bottom = 600 sprite.change_x = -1 sprite.rect.y = 566 sprite.player = self.player sprite.level = self self.enemy_list.add(sprite) sprite = enemies.Enemy(enemies.BEE) sprite.rect.x = 1600 sprite.boundary_left = 1550 sprite.boundary_right = 1750 sprite.boundary_top = 50 sprite.boundary_bottom = 450 sprite.change_y = -2 sprite.rect.y = 100 sprite.player = self.player sprite.level = self self.enemy_list.add(sprite) sprite = enemies.Enemy(enemies.BEE) sprite.rect.x = 1900 sprite.boundary_left = 1850 sprite.boundary_right = 1950 sprite.boundary_top = 50 sprite.boundary_bottom = 450 sprite.change_y = -2 sprite.rect.y = 400 sprite.player = self.player sprite.level = self self.enemy_list.add(sprite) sprite = enemies.Enemy(enemies.BEE) sprite.rect.x = 2140 sprite.boundary_left = 2100 sprite.boundary_right = 2250 sprite.boundary_top = 100 sprite.boundary_bottom = 400 sprite.change_y = -1 sprite.rect.y = 110 sprite.player = self.player sprite.level = self self.enemy_list.add(sprite) sprite = enemies.Enemy(enemies.BEE) sprite.rect.x = 2570 sprite.boundary_left = 2550 sprite.boundary_right = 2650 sprite.boundary_top = 50 sprite.boundary_bottom = 500 sprite.change_y = -2 sprite.rect.y = 110 sprite.player = self.player sprite.level = self self.enemy_list.add(sprite)
def __init__(self, player, bullet, drag): # create level 1 # call the constructor Level.__init__(self, player, bullet, drag) self.background = pygame.image.load('cityscape.png').convert() self.background.set_colorkey(constants.white) self.level_limit = -4000 #bullet = Bullet(player.rect.x, player.rect.y) self.bullet_list.add(bullet) for i in range(6): drag = FlyEnemy() self.enemy_list.add(drag) # Array with type of platform, and x, y location of the platform level = [[platforms.METAL_BLOCK1, 420, 565], [platforms.METAL_BLOCK3, 465, 565], [platforms.METAL_BLOCK2, 510, 565], [platforms.BIG_BLOCK_RIGHT, 555, 530], [platforms.BIG_BLOCK_LEFT, 626, 530], [platforms.GRINDO, 765, 395], [platforms.BLOCK_O_TOP, 905, 395], [platforms.BLOCK_O_TOP, 948, 395], [platforms.REC_O_TOP1, 1025, 370], [platforms.REC_O_TOP1, 1165, 315], # G-Blocks [platforms.BIG_BLOCK, 935, 509], [platforms.LIGHT_NEON_BLOCK, 1021, 509], [platforms.M_COLUMN, 1055, 572], [platforms.LARGE_COLUMN, 1295, 464], [platforms.SMILEY, 1294, 412], # [platforms.BIG_BLOCK_RIGHT2, 1705, 530], [platforms.BIG_BLOCK_RIGHT, 1705, 460], [platforms.BIG_BLOCK_LEFT2, 1776, 530], [platforms.BIG_BLOCK_LEFT, 1776, 460], [platforms.BIG_PIPE_BLOCK, 1730, 373], # - Continuous Path and add enemies [platforms.REC_O_TOP1, 1847, 555], [platforms.REC_O_TOP3, 1944, 555], [platforms.REC_O_TOP2, 2032, 555], [platforms.REC_O_TOP3, 2126, 555], [platforms.REC_O_TOP1, 2214, 555], [platforms.REC_O_TOP1, 2311, 555], [platforms.REC_O_TOP1, 2408, 555], [platforms.BLOCK_O_LEFT, 2501, 525], [platforms.REC_O_TOP2, 2548, 525], [platforms.REC_O_TOP1, 2642, 525], [platforms.REC_O_TOP1, 2739, 525], [platforms.REC_O_TOP1, 2832, 525], [platforms.REC_O_TOP1, 2925, 525], [platforms.REC_O_TOP1, 2918, 525], [platforms.REC_O_TOP1, 3011, 525], [platforms.REC_O_TOP1, 3106, 525], [platforms.BIG_BLOCK_RIGHT2, 3203, 530], [platforms.BIG_BLOCK_RIGHT, 3203, 460], [platforms.BIG_BLOCK_LEFT2, 3274, 530], [platforms.BIG_BLOCK_LEFT, 3274, 460], [platforms.BLOCK_O_TOP, 3345, 475], [platforms.BLOCK_O_TOP, 3388, 475], [platforms.BLOCK_O_TOP, 3421, 475], [platforms.BLOCK_O_TOP, 3464, 475], [platforms.BLOCK_O_TOP, 3507, 475], [platforms.GEAR_BLOCK1, 3345, 520], [platforms.GEAR_BLOCK1, 3345, 559], [platforms.GEAR_BLOCK1, 3345, 598], ] # Go through array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.METAL_RECT1) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 2. """ # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load("Space-PNG-Pic.gif").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -950 # Array with type of platform, and x, y location of the platform. level = [[ platforms.STONE_PLATFORM_MIDDLE, 70, 600], [platforms.STONE_PLATFORM_MIDDLE, 100, 200], [platforms.STONE_PLATFORM_MIDDLE, 200, 550], [platforms.STONE_PLATFORM_MIDDLE, 150, 600], [platforms.STONE_PLATFORM_MIDDLE, 1680, 600], [platforms.STONE_PLATFORM_MIDDLE, 1750, 600], [platforms.STONE_PLATFORM_MIDDLE, 1820, 600], [platforms.STONE_PLATFORM_MIDDLE, 1890, 600], [platforms.EXIT_SIGN, 1890, 530] ] # Go through the array above and add platforms for platform in level: block = platforms.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 220 block.rect.y = 150 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 800 block.rect.y = 101 block.boundary_top = 100 block.boundary_bottom = 649 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 400 block.rect.y = 450 block.boundary_left = 300 block.boundary_right = 500 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1200 block.rect.y = 300 block.boundary_left = 900 block.boundary_right = 1250 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 1550 block.rect.y = 500 block.boundary_left = 800 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block) block = platforms.MovingPlatform(platforms.STONE_PLATFORM_MIDDLE) block.rect.x = 310 block.rect.y = 250 block.boundary_left = 300 block.boundary_right = 550 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)