Exemple #1
0
    def __init__(self, player):

        # Call the parent constructor
        Level.__init__(self, player)

        self.time_allowed = 30
        self.score_multiplier = 12
        self.level_complete_bonus = 400
        self.zone = "Swamp"
        self.background = pygame.image.load(
            "./resources/img/swamp-bg.png").convert_alpha()
        self.background = pygame.transform.scale(self.background, (1000, 800))

        # Array with width, height, x, and y of platform
        level = [
            [90, 70, 340, 730],
            [90, 70, 570, 730],
            [250, 30, 230, 540],
            [250, 30, 520, 540],
            [180, 30, 300, 400],  # mandatory
            [180, 30, 520, 400],  # mandatory
            [230, 30, 250, 140],
            [230, 30, 520, 140],
            [50, 30, 270, 305],
            [50, 30, 680, 305],
            [40, 30, 0, 115],
            [40, 30, 960, 115]
        ]

        walls = [[30, 95, 270, 335], [30, 95, 700, 335], [40, 120, 480, 310],
                 [40, 120, 480, 190], [40, 120, 480, 70], [40, 120, 480, -50],
                 [40, 120, 480, 430], [40, 120, 480, 450]]

        # Go through the array above and add platforms
        for platform in level:
            block = Platform(platform[0], platform[1], self.zone)
            block.rect.x = platform[2]
            block.rect.y = platform[3]
            block.player = self.player
            block.zone = self.zone
            self.platform_list.add(block)

        # Moving platform construct and add to platform list
        block = MovingPlatform(140, 30, self.zone, player)
        block.rect.x = 50
        block.rect.y = 500
        block.boundary_bottom = 750
        block.boundary_top = 115
        block.change_y = -1
        self.platform_list.add(block)

        # Moving platform construct and add to platform list
        block = MovingPlatform(140, 30, self.zone, player)
        block.rect.x = 810
        block.rect.y = 500
        block.boundary_bottom = 750
        block.boundary_top = 115
        block.change_y = 1
        self.platform_list.add(block)

        # Go through and create randomized targets for the level
        for target in range(10):

            target = Pogomonkey()

            # Set a random location for the block, but place it on a platform within the list
            # First select a random plat from the list in the level
            random_plat = random.randrange(len(level))
            random_plat = level[random_plat]

            # Grab it's X and Y and set this iteration of target's X and Y to be within a "standing" bound
            random_plat_x = random_plat[2]
            random_plat_y = random_plat[3]
            target.rect.x = random.randrange(
                random_plat_x, random_plat_x + (random_plat[0] - target.width))
            target.rect.y = random_plat_y - target.height

            # Move distance allowed for this plat
            target.move_start = random_plat[2]
            target.jump_start = random_plat[3]

            # Add the block to the list of objects
            self.target_list.add(target)

        # Generate walls after enemies so none spawn on it
        for platform in walls:
            block = Wall(platform[0], platform[1], self.zone)
            block.rect.x = platform[2]
            block.rect.y = platform[3]
            block.player = self.player
            block.zone = self.zone
            self.platform_list.add(block)
Exemple #2
0
    def __init__(self, player):

        # Call the parent constructor
        Level.__init__(self, player)

        self.time_allowed = 40
        self.score_multiplier = 12
        self.level_complete_bonus = 600
        self.zone = "Underwater"
        self.background = pygame.image.load(
            "./resources/img/atlantis-bg.png").convert_alpha()
        self.background = pygame.transform.scale(self.background, (1000, 800))

        # Array with width, height, x, and y of platform
        level = [
            [90, 30, 0, 770],
            [90, 30, 910, 770],
            [90, 30, 200, 680],
            [90, 30, 710, 680],
            [90, 30, 0, 590],
            [90, 30, 910, 590],
            [90, 30, 200, 500],
            [90, 30, 710, 500],
            [90, 30, 0, 410],
            [90, 30, 910, 410],
            [90, 30, 200, 320],
            [90, 30, 710, 320],
            [90, 30, 0, 230],
            [90, 30, 910, 230],
            [90, 30, 200, 140],
            [90, 30, 710, 140],
        ]

        walls = [
            [40, 120, 290, 680],
            [40, 120, 670, 680],
            [40, 120, 290, 560],
            [40, 120, 670, 560],
            [40, 120, 290, 440],
            [40, 120, 670, 440],
            [40, 120, 290, 320],
            [40, 120, 670, 320],
            [40, 120, 290, 200],
            [40, 120, 670, 200],
            [40, 120, 290, 80],
            [40, 120, 670, 80],
        ]

        # Go through the array above and add platforms
        for platform in level:
            block = Platform(platform[0], platform[1], self.zone)
            block.rect.x = platform[2]
            block.rect.y = platform[3]
            self.platform_list.add(block)

        # Moving platform construct and add to platform list
        block = MovingPlatform(100, 30, self.zone, player)
        block.rect.x = 350
        block.rect.y = 500
        block.boundary_bottom = 800
        block.boundary_top = 50
        block.change_y = 1
        self.platform_list.add(block)

        # Moving platform construct and add to platform list
        block = MovingPlatform(100, 30, self.zone, player)
        block.rect.x = 550
        block.rect.y = 500
        block.boundary_bottom = 800
        block.boundary_top = 50
        block.change_y = -1
        self.platform_list.add(block)

        # Deliberate target locations for level as per design
        for i in range(len(level)):
            target = Bikefish()

            platform = level[i]

            # Grab it's X and Y and set this iteration of target's X and Y to be within a "standing" bound
            plat_x = platform[2]
            plat_y = platform[3]
            target.rect.x = random.randrange(
                plat_x, plat_x + (platform[0] - target.width))
            target.rect.y = plat_y - target.height

            # Add the block to the list of objects
            self.target_list.add(target)

        # Generate walls after enemies so none spawn on it
        for platform in walls:
            block = Wall(platform[0], platform[1], self.zone)
            block.rect.x = platform[2]
            block.rect.y = platform[3]
            block.player = self.player
            block.zone = self.zone
            self.platform_list.add(block)
Exemple #3
0
    def __init__(self, player):

        # Call the parent constructor
        Level.__init__(self, player)

        self.time_allowed = 40
        self.score_multiplier = 12
        self.level_complete_bonus = 300
        self.zone = "City"
        self.background = pygame.image.load(
            "./resources/img/city-bg.png").convert_alpha()

        # Array with width, height, x, and y of platform
        level = [[100, 60, 250, 740], [100, 60, 660, 740], [150, 40, 190, 110],
                 [150, 40, 640, 110], [150, 40, 0, 530], [150, 40, 850, 530],
                 [170, 40, 0, 330], [170, 40, 830, 330]]

        walls = [[30, 130, 170, 240], [30, 130, 800, 240]]

        # Go through the array above and add platforms
        for platform in level:
            block = Platform(platform[0], platform[1], self.zone)
            block.rect.x = platform[2]
            block.rect.y = platform[3]
            block.player = self.player
            block.zone = self.zone
            self.platform_list.add(block)

        # Moving platform construct and add to platform list
        block = MovingPlatform(200, 40, self.zone, player)
        block.rect.x = 400
        block.rect.y = 140
        block.boundary_bottom = 705
        block.boundary_top = 115
        block.change_y = -2
        self.platform_list.add(block)

        # Go through and create randomized targets for the level
        for target in range(10):

            target = Cop()

            # Set a random location for the block, but place it on a platform within the list
            # First select a random plat from the list in the level
            random_plat = random.randrange(len(level))
            random_plat = level[random_plat]

            # Grab it's X and Y and set this iteration of target's X and Y to be within a "standing" bound
            random_plat_x = random_plat[2]
            random_plat_y = random_plat[3]
            target.rect.x = random.randrange(
                random_plat_x, random_plat_x + (random_plat[0] - target.width))
            target.rect.y = random_plat_y - target.height

            # Move distance allowed for this plat
            target.move_start = random_plat[2]
            target.move_end = random_plat[2] + random_plat[0]

            # Add the block to the list of objects
            self.target_list.add(target)

        # Deliberate target locations for level as per design
        for i in range(6, 8):
            target = Cop()

            platform = level[i]

            # Grab it's X and Y and set this iteration of target's X and Y to be within a "standing" bound
            plat_x = platform[2]
            plat_y = platform[3]
            target.rect.x = random.randrange(
                plat_x, plat_x + (platform[0] - target.width))
            target.rect.y = plat_y - target.height

            # Move distance allowed for this plat
            target.move_start = platform[2]
            target.move_end = platform[2] + platform[0]

            # Add the block to the list of objects
            self.target_list.add(target)

        # Generate walls after enemies so none spawn on it
        for platform in walls:
            block = Wall(platform[0], platform[1], self.zone)
            block.rect.x = platform[2]
            block.rect.y = platform[3]
            block.player = self.player
            block.zone = self.zone
            self.platform_list.add(block)