def levelSelected(level): if level == stage1icon: platform1 = objects.Platform(-58, -48, 2, 2.70) platform2 = objects.Platform(526, -48, 2, 2.70) platform3 = objects.Platform(210, -80, 2.47, 2.50) startGame(250, 150, 375, 150, stage1) elif level == stage2icon: platform1 = objects.Platform(-45, -95, 1.5, 2.50) platform2 = objects.Platform(555, -45, 1.5, 2) platform3 = objects.Platform(155, -80, 3.48, 2.50) platform4 = objects.Platform(185, 260, .65, .1) platform5 = objects.Platform(407, 260, .65, .1) startGame(250, 150, 375, 150, stage2) elif level == stage3icon: platform1 = objects.Platform(70, -80, 4.83, 1.65) startGame(250, 150, 375, 150, stage3)
def __init__(self): self.running = True self.platform = objects.Platform() self.player = objects.Player(WIDTH, self.platform) self.drops = [ objects.WaterDrop(WIDTH, HEIGHT) for x in range(START_DROPS) ] self.amount_of_drops = START_DROPS self.lives = 5 self.title_running = True self.count = 0 self.time = 0
def setGroups(self, neutral, enemy): for enemy in enemy: block = objects.Harmful(enemy[0]) block.rect.x = enemy[1] block.rect.y = enemy[2] block.player = self.player self.game.enemygroup.add(block) for platform in neutral: block = objects.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.game.entities.add(block)
import pygame import objects pygame.init() #Start Pygame background_color = (121, 187, 210) # light blue screen = pygame.display.set_mode((800, 600)) #Start the screen clock = pygame.time.Clock() player = objects.Player(100, 100, 50, 50) ground = objects.Platform(0, 500, 800, 100) top = objects.Platform(0, -100, 800, 100) left_side = objects.Platform(-10, -10 * 100, 10, 10 * 100 + 600) right_side = objects.Platform(800, -10 * 100, 10, 10 * 100 + 600) platforms = [ objects.Platform(200, 400, 400, 25), objects.Platform(500, 100, 200, 25) ] game_objects = [ground, left_side, right_side, top] + platforms blackholes = [ objects.BlackHole(300, 300, 10, 10), objects.BlackHole(400, 200, 10, 10) ] running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: # The user closed the window! running = False # Stop running screen.fill(background_color)
def __init__(self, player): Level.__init__(self, player) self.background = pygame.image.load("background.png").convert() self.level_limit = -1300 self.level = [] enemies = [[objects.HOT_MAGMA, -750, 765], [objects.HOT_MAGMA, -450, 765], [objects.HOT_MAGMA, -750, 565], [objects.HOT_MAGMA, -450, 565], [objects.HOT_MAGMA, -750, 365], [objects.HOT_MAGMA, -450, 365], [objects.HOT_MAGMA, -450, 105]] misc_list = [[objects.HEART, 0, 0], [objects.HEART, 50, 0], [objects.HEART, 100, 0]] for enemy in enemies: block = objects.Harmful(enemy[0]) block.rect.x = enemy[1] block.rect.y = enemy[2] block.player = self.player self.enemy_list.add(block) for platform in self.level: block = objects.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) for misc in misc_list: block = objects.Misc(misc[0]) block.rect.x = misc[1] block.rect.y = misc[2] block.player = self.player self.misc_list.add(block) block = objects.MovingPlatform( objects.FLOOR) #add the moving platforms (direction: horizontal) block.rect.x = 0 block.rect.y = 750 block.boundary_left = -380 block.boundary_right = 2000 block.change_x = -2 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingPlatform(objects.FLOOR) block.rect.x = 385 block.rect.y = 750 block.boundary_left = -380 block.boundary_right = 2000 block.change_x = -2 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingPlatform(objects.FLOOR) block.rect.x = 770 block.rect.y = 750 block.boundary_left = -380 block.boundary_right = 2000 block.change_x = -2 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingPlatform(objects.FLOOR) block.rect.x = 1155 block.rect.y = 750 block.boundary_left = -380 block.boundary_right = 2000 block.change_x = -2 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingPlatform(objects.FLOOR) block.rect.x = 1535 block.rect.y = 750 block.boundary_left = -380 block.boundary_right = 2000 block.change_x = -2 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingHarmful( objects.BAT) #add the moving enemies (direction: horizontal) block.rect.x = 2000 block.rect.y = 550 block.boundary_left = -380 block.boundary_bottom = 800 block.change_x = -4 block.player = self.player block.level = self self.enemy_list.add(block) block = objects.MovingHarmful(objects.BAT) block.rect.x = 1600 block.rect.y = 550 block.boundary_left = -380 block.boundary_bottom = 800 block.change_x = -4 block.player = self.player block.level = self self.enemy_list.add(block) block = objects.MovingHarmful(objects.BAT) block.rect.x = 1800 block.rect.y = 300 block.boundary_left = -380 block.boundary_bottom = 800 block.change_x = -4 block.player = self.player block.level = self self.enemy_list.add(block) block = objects.MovingPlatform( objects.SMALL_PLAT) #small moving platform (direction: vertical) block.rect.x = 200 block.rect.y = 500 block.boundary_bottom = 650 block.boundary_top = 200 block.boundary_left = -380 block.boundary_right = 1900 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingPlatform(objects.SMALL_PLAT) block.rect.x = 900 block.rect.y = 120 block.boundary_bottom = 650 block.boundary_top = 100 block.boundary_left = -380 block.boundary_right = 1900 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingHarmful( objects.PUMPKIN) #add the moving enemies(direction: vertical) block.rect.x = 500 block.rect.y = -500 block.boundary_bottom = 750 block.change_y = 4 block.player = self.player block.level = self self.enemy_list.add(block) block = objects.MovingHarmful(objects.PUMPKIN) block.rect.x = 200 block.rect.y = -1500 block.boundary_bottom = 750 block.change_y = 4 block.player = self.player block.level = self self.enemy_list.add(block)
def __init__(self, player): Level.__init__(self, player) self.background = pygame.image.load("back4.png").convert() self.level_limit = -1300 self.level = [[objects.FLOOR, 390, 700], [objects.AIR_PLAT, 500, 400]] enemies = [[objects.HOT_MAGMA, 0, 765], [objects.HOT_MAGMA, 295, 765], [objects.HOT_MAGMA, 2 * 295, 765], [objects.HOT_MAGMA, 3 * 295, 765], [objects.HOT_MAGMA, 4 * 295, 765], [objects.HOT_MAGMA, -250, 765], [objects.HOT_MAGMA, -500, 765]] misc_list = [[objects.HEART, 0, 0], [objects.HEART, 50, 0], [objects.HEART, 100, 0]] for enemy in enemies: block = objects.Harmful(enemy[0]) block.rect.x = enemy[1] block.rect.y = enemy[2] block.player = self.player self.enemy_list.add(block) for platform in self.level: block = objects.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) for misc in misc_list: block = objects.Misc(misc[0]) block.rect.x = misc[1] block.rect.y = misc[2] block.player = self.player self.misc_list.add(block) block = objects.MovingHarmful(objects.WITCH) block.rect.x = 1600 block.rect.y = 350 block.boundary_left = -380 block.boundary_bottom = 550 block.change_x = -8 block.player = self.player block.level = self self.enemy_list.add(block) block = objects.MovingPlatform(objects.AIR_PLAT) block.rect.x = 100 block.rect.y = 200 block.boundary_bottom = 470 block.boundary_top = 200 block.boundary_left = -100 block.boundary_right = 1000 block.change_y = -2 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingPlatform(objects.AIR_PLAT) block.rect.x = 900 block.rect.y = 400 block.boundary_bottom = 470 block.boundary_top = 200 block.boundary_left = -100 block.boundary_right = 1000 block.change_y = -3 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingPlatform(objects.FLOOR) block.rect.x = 1200 block.rect.y = 700 block.boundary_bottom = 700 block.boundary_top = 200 block.boundary_left = -380 block.boundary_right = 1000 block.change_x = -2 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingPlatform(objects.AIR_PLAT) block.rect.x = 400 block.rect.y = 600 block.boundary_bottom = 700 block.boundary_top = 200 block.boundary_left = -100 block.boundary_right = 2000 block.change_x = -2 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingPlatform(objects.AIR_PLAT) block.rect.x = 1200 block.rect.y = 600 block.boundary_bottom = 700 block.boundary_top = 200 block.boundary_left = -100 block.boundary_right = 2000 block.change_x = -2 block.player = self.player block.level = self self.platform_list.add(block) ''' block = objects.MovingPlatform(objects.FLOOR) block.rect.x = 1600 block.rect.y = 700 block.boundary_bottom = 700 block.boundary_top = 200 block.boundary_left = -380 block.boundary_right = 2000 block.change_x = -2 block.player = self.player block.level = self self.platform_list.add(block) block = objects.MovingPlatform(objects.FLOOR) block.rect.x = 800 block.rect.y = 700 block.boundary_bottom = 700 block.boundary_top = 200 block.boundary_left = -380 block.boundary_right = 2000 block.change_x = -2 block.player = self.player block.level = self self.platform_list.add(block) ''' block = objects.MovingHarmful(objects.BAT) block.rect.x = 1800 block.rect.y = 300 block.boundary_left = -380 * 4 block.boundary_bottom = 800 block.change_x = -4 block.player = self.player block.level = self self.enemy_list.add(block) ''' block = objects.MovingHarmful(objects.BAT) block.rect.x = 1000 block.rect.y = 800 block.boundary_left = -380 block.boundary_bottom = 800 block.change_x = -4 block.player = self.player block.level = self self.enemy_list.add(block) ''' block = objects.MovingHarmful(objects.BAT) block.rect.x = 600 block.rect.y = 800 block.boundary_left = -380 * 3 block.boundary_bottom = 800 block.change_x = -4 block.player = self.player block.level = self self.enemy_list.add(block) block = objects.MovingHarmful( objects.PUMPKIN) # add the moving enemies(direction: vertical) block.rect.x = 500 block.rect.y = -1500 block.boundary_bottom = 750 block.change_y = 4 block.player = self.player block.level = self self.enemy_list.add(block)
def __init__(self, player): Level.__init__(self, player, player.game) self.background = pygame.image.load("background1.png").convert() #Invisible obstacles stop the player from going out of bounds self.level = [[objects.INV_OBSTACLE, -50, -400], [objects.INV_OBSTACLE, -50, 0], [objects.INV_OBSTACLE, -50, 408]] self.harmful_objects = [[objects.SPIKES, 480, 768],[objects.SPIKES, 600, 768], [objects.SPIKES, 720, 768], [objects.SPIKES, 840, 768], [objects.SPIKES, 450, 185], [objects.SPIKES, 578, 185], [objects.SPIKES, 706, 185], [objects.SPIKES, 833, 185],] # Add the hearts and enemy/platform sprites to spritegroups in class Game self.setLives() self.setGroups(self.level, self.harmful_objects) block = objects.Bat(500, 600, 2) block.boundary_left = 300 block.player = self.player self.game.enemygroup2.add(block) block = objects.Bat(350, 285, 2) block.boundary_left = 200 block.boundary_right = 630 block.player = self.player self.game.enemygroup2.add(block) block = objects.Bat(300, 50, 2) block.boundary_left = 150 block.boundary_right = 780 block.player = self.player self.game.enemygroup2.add(block) block = objects.Bat(1300, 600, 2) block.boundary_left = 1100 block.boundary_right = 1500 block.player = self.player self.game.enemygroup2.add(block) block = objects.Bat(1300, 400, 2) block.boundary_left = 1000 block.boundary_right = 1500 block.player = self.player self.game.enemygroup2.add(block) block = objects.Bat(1100, 300, 2) block.boundary_left = 1000 block.boundary_right = 1500 block.player = self.player self.game.enemygroup2.add(block) block = objects.Bat(1100, 200, 2) block.boundary_left = 1000 block.boundary_right = 1500 block.player = self.player self.game.enemygroup2.add(block) ''' block = objects.Harmful(objects.SPIKES) block.rect.x = 330 block.rect.y = 550 block.player = self.player block.level = self self.game.entities.add(block) ''' block = objects.Platform(objects.FLOOR) block.rect.x = 0 block.rect.y = 750 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.FLOOR) block.rect.x = 480 block.rect.y = 783 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.FLOOR) block.rect.x = 960 block.rect.y = 750 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.FLOOR) block.rect.x = 1200 block.rect.y = 750 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.FLOOR) block.rect.x = 1350 block.rect.y = 750 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 960 block.rect.y = 141 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 960 block.rect.y = 237 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 960 block.rect.y = 333 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 960 block.rect.y = 429 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 1810 block.rect.y = 650 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 1810 block.rect.y = 650 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 1810 block.rect.y = 555 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 1810 block.rect.y = 460 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 1810 block.rect.y = 365 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 1810 block.rect.y = 270 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 1810 block.rect.y = 175 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 1810 block.rect.y = 80 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.CHAINS) block.rect.x = 1810 block.rect.y = -15 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.BOX_S_STRIPPED) block.rect.x = 960 block.rect.y = 686 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.BOX_S_STRIPPED) block.rect.x = 960 block.rect.y = 623 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.BOX_S_STRIPPED) block.rect.x = 960 block.rect.y = 560 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.BOX_S_STRIPPED) block.rect.x = 960 block.rect.y = 497 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.BOX_B_STRIPPED) block.rect.x = 1023 block.rect.y = 653 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_W_WINDOWS) block.rect.x = 270 block.rect.y = 520 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_W_WINDOWS) block.rect.x = 270 block.rect.y = 270 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_W_WINDOWS) block.rect.x = 843 block.rect.y = 520 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_W_WINDOWS) block.rect.x = 1227 block.rect.y = 520 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_W_WINDOWS) block.rect.x = -300 block.rect.y = 270 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_W_WINDOWS) block.rect.x = 843 block.rect.y = 270 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_W_WINDOWS) block.rect.x = 1227 block.rect.y = 270 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_BOXES) block.rect.x = 0 block.rect.y = 143 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_BOXES) block.rect.x = 764 block.rect.y = 143 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_BOXES) block.rect.x = 380 block.rect.y = 143 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_BOXES) block.rect.x = 0 block.rect.y = 0 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_BOXES) block.rect.x = 764 block.rect.y = 0 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Backgrounds(objects.BACKGROUND_BLACK_BOXES) block.rect.x = 380 block.rect.y = 0 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Platform(objects.FLOOR) block.rect.x = -125 block.rect.y = 526 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Backgrounds(objects.BACKGROUND_W_STAIRS) block.rect.x = 0 block.rect.y = 526 block.player = self.player block.level = self self.game.backgrounds.add(block) block = objects.Platform(objects.PLATFORM_DARK_GREY) block.rect.x = 500 block.rect.y = 200 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.PLATFORM_DARK_GREY) block.rect.x = 720 block.rect.y = 200 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.PLATFORM_DARK_GREY) block.rect.x = 256 block.rect.y = 200 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.PLATFORM_DARK_GREY) block.rect.x = 960 block.rect.y = 113 block.player = self.player block.level = self self.game.entities.add(block) block = objects.MovingPlatform(objects.SMALL_PLAT) block.rect.x = 770 block.rect.y = 400 block.boundary_bottom = 680 block.boundary_top = 350 block.boundary_left = -380 block.boundary_right = 1900 block.change_y = 1 block.player = self.player block.level = self self.game.entities.add(block) block = objects.MovingPlatform(objects.SMALL_PLAT) block.rect.x = 1300 block.rect.y = 400 block.boundary_bottom = 630 block.boundary_top = 150 block.boundary_left = -380 block.boundary_right = 1900 block.change_y = 1 block.player = self.player block.level = self self.game.entities.add(block) block = objects.MovingPlatform(objects.SMALL_PLAT) block.rect.x = 0 block.rect.y = 250 block.boundary_bottom = 450 block.boundary_top = 150 block.boundary_left = -380 block.boundary_right = 1900 block.change_y = 1 block.player = self.player block.level = self self.game.entities.add(block) block = objects.MovingPlatform(objects.PLATFORM_GREY_SMALL) block.rect.x = 700 block.rect.y = 150 block.boundary_bottom = 450 block.boundary_top = 150 block.boundary_left = 450 block.boundary_right = 900 block.change_x = 1 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.BOX_S_STRIPPED) block.rect.x = 200 block.rect.y = 463 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.PLATFORM_GREY_SMALL) block.rect.x = 550 block.rect.y = 700 block.player = self.player block.level = self self.game.entities.add(block) block = objects.Platform(objects.PLATFORM_GREY_SMALL) block.rect.x = 550 block.rect.y = 400 block.player = self.player block.level = self self.game.entities.add(block) ''' block = objects.MovingPlatform(objects.SMALL_PLAT) block.rect.x = 550 block.rect.y = 700 block.boundary_bottom = 700 block.boundary_top = 100 block.boundary_left = 550 block.boundary_right = 750 block.change_x = -1 block.player = self.player block.level = self self.game.entities.add(block) ''' '''
def __init__(self, player): Level.__init__(self, player) self.background = pygame.image.load("background1-720.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -1300 level = [[objects.BUILDING1, 0, 380], [objects.STONE_PLATFORM_2, 700, 280], [objects.STONE_PLATFORM_1, 210, 400], [objects.BOX_STRIPPED, 0, 285], [objects.BOX_STRIPPED, 0, 198], [objects.OBSTACLE, -35, 379], [objects.OBSTACLE, -35, 160], [objects.OBSTACLE, -35, 2], [objects.STONE_PLATFORM_1, 1000, 670], [objects.SCIBOX, 720, 214], [objects.HUGE_PLAT, 1000, 407], [objects.HUGE_PLAT, 1868, 407], [objects.SCIBOX, 750, 533], [objects.OBSTACLE, 2500, 379], [objects.OBSTACLE, 2500, 160], [objects.OBSTACLE, 2500, 2], [objects.LADDER, 2450, 400]] enemies = [[objects.SPIKES_HORIZONTAL, 870, 580], [objects.SPIKES_HORIZONTAL, 820, 580], [objects.SPIKES_HORIZONTAL, 1380, 580], [objects.SPIKES_HORIZONTAL, 1500, 580], [objects.SPIKES_HORIZONTAL, 1620, 580], [objects.SPIKES_HORIZONTAL, 1740, 580]] level_coin = [[objects.COIN_SILVER, 120, 140], [objects.COIN_SILVER, 120, 160], [objects.COIN_SILVER, 720, 100], [objects.COIN_SILVER, 700, 550], [objects.COIN_SILVER, 900, 450], [objects.COIN_SILVER, 1600, 150], [objects.COIN_SILVER, 1700, 150], [objects.COIN_SILVER, 1800, 150]] for enemy in enemies: block = objects.Harmful(enemy[0]) block.rect.x = enemy[1] block.rect.y = enemy[2] block.player = self.player self.enemy_list.add(block) for platform in level: block = objects.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) for coin in level_coin: block = objects.Currency(coin[0]) block.rect.x = coin[1] block.rect.y = coin[2] block.player = self.player self.coin_list.add(block) block = objects.MovingPlatform(objects.STONE_PLATFORM_1) 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): # Call the parent constructor Level.__init__(self, player) self.background = pygame.image.load("background3-720.png").convert() self.background.set_colorkey(constants.WHITE) self.level_limit = -1200 # Array with type of platform, and x, y location of the platform. level = [[objects.BUILDING1, -200, 380], [objects.OBSTACLE, -210, 379], [objects.OBSTACLE, -110, 160], [objects.OBSTACLE, -110, 2], [objects.OBSTACLE, 100, 2], [objects.STONE_PLATFORM_1, 230, 450], [objects.DOUBLE_BOX, 391, 322], [objects.TOWER, 548, 250], [objects.BOX_STRIPPED, 690, 153], [objects.STONE_PLATFORM_2, 540, -23], [objects.STONE_PLATFORM_1, 1030, 340], [objects.STONE_PLATFORM_2, 940, -23], [objects.SCIBOX, 1130, 277], [objects.STONE_PLATFORM_2, 1440, 0], [objects.HUGE_PLAT, 1850, 6], [objects.TOWER, 1850, 350], [objects.HUGE_PLAT, 2232, 6], [objects.HUGE_PLAT, 2614, 6], [objects.TOWER, 2138, 350], [objects.TOWER, 2426, 350]] enemies = [[objects.SPIKES_H, 699, 9], [objects.SPIKES_H, 659, 9], [objects.SPIKES_H, 539, 9], [objects.SPIKE, 870, 580], [objects.SPIKES_V, 538, 500], [objects.SPIKES_H, -30, 180], [objects.SPIKES_V, 538, 380], [objects.SPIKES_V, 538, 250], [objects.LAMP, 1060, 12], [objects.SPIKES_H, 1862, 198], [objects.SPIKES_H, 1440, 33], [objects.SPIKE, 1570, 30], [objects.SPIKE, 1598, 30], [objects.SPIKES_H, 1625, 33], [objects.SPIKES_HORIZONTAL, 1380, 585], [objects.SPIKES_HORIZONTAL, 1500, 585], [objects.SPIKES_HORIZONTAL, 1620, 585], [objects.SPIKES_HORIZONTAL, 1730, 585], [objects.SPIKES_HORIZONTAL, 920, 585], [objects.SPIKES_HORIZONTAL, 1160, 585]] level_coin = [[objects.COIN_SILVER, 70, 20], [objects.COIN_SILVER, 70, 40], [objects.COIN_SILVER, 70, 60], [objects.COIN_SILVER, 70, 80], [objects.COIN_SILVER, 70, 100], [objects.COIN_SILVER, 70, 120], [objects.COIN_SILVER, 70, 140], [objects.COIN_SILVER, 70, 160], [objects.COIN_SILVER, 30, 20], [objects.COIN_SILVER, 30, 40], [objects.COIN_SILVER, 30, 60], [objects.COIN_SILVER, 30, 80], [objects.COIN_SILVER, 30, 100], [objects.COIN_SILVER, 30, 120], [objects.COIN_SILVER, 30, 140], [objects.COIN_SILVER, 30, 160], [objects.COIN_SILVER, 1000, 40], [objects.COIN_SILVER, 1180, 40], [objects.COIN_SILVER, 1587, 74], [objects.COIN_SILVER, 1325, 470], [objects.COIN_SILVER, 1120, 470]] for enemy in enemies: block = objects.Harmful(enemy[0]) block.rect.x = enemy[1] block.rect.y = enemy[2] block.player = self.player self.enemy_list.add(block) for platform in level: block = objects.Platform(platform[0]) block.rect.x = platform[1] block.rect.y = platform[2] block.player = self.player self.platform_list.add(block) for coin in level_coin: block = objects.Currency(coin[0]) block.rect.x = coin[1] block.rect.y = coin[2] block.player = self.player self.coin_list.add(block) # Add a custom moving platform block = objects.MovingPlatform(objects.STONE_PLATFORM_1) 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 create_plat(x, y, players): platform = objects.Platform(x, y, players) platforms.add(platform)