示例#1
0
    def grow_probe(self):
        bottom = self.container_bg.rect.bottom
        self.container_bg.name = '300ne/broken_container_bg'
        self.container_bg.update_image()
        self.container_bg.rect.bottom = bottom

        bottom = self.container.rect.bottom
        self.container.name = '300ne/broken_container'
        self.container.update_image()
        self.container.rect.bottom = bottom

        self.level.artifact.remove()
        self.level.engine.player.remove()

        self.large_probe = Sprite('probe_large')
        self.main_layer.add(self.large_probe)
        self.large_probe.collidable = False
        self.large_probe.obey_gravity = False
        self.large_probe.move_to(
            self.container.rect.left +
            (self.container.rect.width - self.large_probe.rect.width) / 2,
            self.container.rect.bottom - 2 * self.large_probe.rect.height)

        # We're going to force updates to get things in the right order.
        self.container.hide()
        self.container.show()
        self.container_base.hide()
        self.container_base.show()
示例#2
0
    def on_container_added(self):
        player = self.level.engine.player
        self.questionmark = Sprite('questionmark')
        self.questionmark.collidable = False
        self.main_layer.add(self.questionmark)
        self.questionmark.move_to(
            player.rect.left +
            (player.rect.width - self.questionmark.rect.width) / 2,
            player.rect.top - self.questionmark.rect.height - 10)

        timer = Timer(300, self.hide_questionmark, one_shot=True)
        timer.start()
示例#3
0
    def setup(self):
        level_width, level_height = self.size

        toxicwaste = TiledSprite('2300ad/toxicwaste', 5, 1)
        toxicwaste.lethal = True
        self.main_layer.add(toxicwaste)
        toxicwaste.move_to(0, level_height - toxicwaste.rect.height)

        ground = TiledSprite('2300ad/ground', 15, 1)
        self.main_layer.add(ground)
        ground.move_to(toxicwaste.rect.right, level_height - ground.rect.height)

        toxicwaste = TiledSprite('2300ad/toxicwaste', 8, 1)
        toxicwaste.lethal = True
        self.main_layer.add(toxicwaste)
        toxicwaste.move_to(ground.rect.right,
                           level_height - toxicwaste.rect.height)

        pyramid = Sprite('2300ad/pyramid')
        self.bg_layer.add(pyramid)
        pyramid.move_to(922, ground.rect.top - pyramid.rect.height)

        bubble = Sprite('2300ad/pyramid_bubble')
        self.bg_layer.add(bubble)
        bubble.move_to(
            pyramid.rect.left + (pyramid.rect.width - bubble.rect.width) / 2,
            ground.rect.top - bubble.rect.height)

        pole = LightningPole()
        self.main_layer.add(pole)
        pole.move_to(pyramid.rect.left + 100,
                     ground.rect.top - pole.rect.height)

        pole = LightningPole()
        self.main_layer.add(pole)
        pole.move_to(2600, ground.rect.top - pole.rect.height)

        self.main_layer.add(self.level.hoverboard)
        self.level.hoverboard.move_to(
            bubble.rect.right + 200,
            ground.rect.top - self.level.hoverboard.rect.height - 30)

        sign = QuarantineSign()
        self.main_layer.add(sign)
        sign.move_to(bubble.rect.left - sign.rect.width - 200,
                     ground.rect.top - 300)

        sign = QuarantineSign()
        self.main_layer.add(sign)
        sign.move_to(bubble.rect.right + 200, ground.rect.top - 300)
示例#4
0
    def setup(self):
        level_width, level_height = self.size

        tiles_x = self.size[0] / 144
        ground = TiledSprite('1000ad/ground', tiles_x, 1)
        self.main_layer.add(ground)
        ground.move_to(0, level_height - ground.rect.height)

        cactus = Cactus()
        self.main_layer.add(cactus)
        cactus.move_to(100, ground.rect.top - cactus.rect.height)

        pyramid = Sprite('1000ad/pyramid')
        self.bg_layer.add(pyramid)
        pyramid.move_to(922, ground.rect.top - pyramid.rect.height)

        cactus = Cactus()
        self.main_layer.add(cactus)
        cactus.move_to(pyramid.rect.left + 100,
                       ground.rect.top - cactus.rect.height)

        cactus = Cactus()
        self.main_layer.add(cactus)
        cactus.move_to(2600, ground.rect.top - cactus.rect.height)

        self.pyramid_door.destination = self.time_period.areas['pyramid'].door
        self.main_layer.add(self.pyramid_door)
        self.pyramid_door.move_to(
            pyramid.rect.left + 621,
            pyramid.rect.bottom - self.pyramid_door.rect.height)

        snake = Snake()
        self.main_layer.add(snake)
        snake.move_to(pyramid.rect.left - snake.rect.width,
                      ground.rect.top - snake.rect.height)

        # Artifact
        self.level.add_artifact(self, cactus.rect.right + 100, ground.rect.top)
示例#5
0
    def setup(self):
        level_width, level_height = self.size

        lava_name = '65000000bc/lava_pool'
        tiles_x = level_width / load_image(lava_name).get_width()
        lava = TiledSprite('65000000bc/lava_pool', tiles_x, 1)
        lava.lethal = True
        self.main_layer.add(lava)
        lava.move_to(0, level_height - lava.rect.height)

        cliff = Sprite('40000000ad/cliff_left')
        cliff.use_pixel_collisions = True
        self.main_layer.add(cliff)
        cliff.move_to(0, level_height - cliff.rect.height)

        self.main_layer.add(self.bluebox)
        self.bluebox.move_to(60, cliff.rect.top - self.bluebox.rect.height)
        self.bluebox.destination = self.time_period.areas['bluebox'].door

        cliff = Sprite('40000000ad/cliff_middle')
        cliff.use_pixel_collisions = True
        self.main_layer.add(cliff)
        cliff.move_to(1720, level_height - cliff.rect.height)
示例#6
0
    def setup(self):
        level_width, level_height = self.size

        # Ground
        tiles_x = self.size[0] / 32
        ground = TiledSprite("ground", tiles_x, 1)
        self.main_layer.add(ground)
        ground.move_to(0, self.size[1] - ground.rect.height)

        building_rect = self.BUILDING_RECT.move(0, ground.rect.top - self.BUILDING_RECT.height)

        # Building background
        building_bg = Box(*building_rect.size)
        self.bg_layer.add(building_bg)
        building_bg.move_to(*building_rect.topleft)

        # First floor
        floor1 = Box(building_rect.width, self.GROUND_HEIGHT, self.FLOOR_COLOR)
        self.main_layer.add(floor1)
        floor1.move_to(building_rect.left, ground.rect.top)

        # Second floor
        floor2 = Box(building_rect.width, self.GROUND_HEIGHT, self.FLOOR_COLOR)
        self.main_layer.add(floor2)
        floor2.move_to(building_rect.left, building_rect.top + (building_rect.height - floor2.rect.height) / 2)

        # Left wall of building
        box = Box(self.WALL_WIDTH, building_rect.height, self.WALL_COLOR)
        self.main_layer.add(box)
        box.move_to(building_rect.left, building_rect.top)

        # Right wall of the building
        right_wall = Box(self.WALL_WIDTH, building_rect.height, self.WALL_COLOR)
        self.main_layer.add(right_wall)
        right_wall.move_to(building_rect.right - self.WALL_WIDTH, building_rect.top)

        # Ceiling
        box = Box(building_rect.width, self.GROUND_HEIGHT)
        self.main_layer.add(box)
        box.move_to(building_rect.left, building_rect.top)

        # Top elevator
        elevator1 = Elevator()
        self.main_layer.add(elevator1)
        elevator1.move_to(building_rect.left + 100, building_rect.top - elevator1.rect.height)

        # Bottom elevator
        elevator2 = Elevator()
        self.main_layer.add(elevator2)
        elevator2.move_to(elevator1.rect.left, floor2.rect.top - elevator2.rect.height)

        # Link up the elevators
        elevator1.destination = elevator2
        elevator2.destination = elevator1

        # Dynamite
        self.main_layer.add(self.level.dynamite)
        self.level.dynamite.move_to(
            right_wall.rect.left - self.level.dynamite.rect.width - 20,
            floor2.rect.top - self.level.dynamite.rect.height,
        )
        # self.level.dynamite.move_to(
        #    200, ground.rect.top - self.level.dynamite.rect.height)

        # Mountain
        mountain = Mountain()
        mountain.add_to(self)
        mountain.move_to(1300, ground.rect.top - mountain.rect.height)

        platform = Sprite("1999ad/lavamatics_platform")
        self.main_layer.add(platform)
        platform.move_to(1841, mountain.rect.bottom - platform.rect.height - 500)

        platform = Sprite("1999ad/l_tube")
        self.main_layer.add(platform)
        platform.move_to(2140, mountain.rect.bottom - platform.rect.height - 450)
示例#7
0
    def setup(self):
        tiles_x = self.size[0] / 32
        ground = TiledSprite("ground", tiles_x, 1)
        self.main_layer.add(ground)
        ground.move_to(0, self.size[1] - ground.rect.height)

        hills = Sprite("600ad/hills_1")
        self.bg_layer.add(hills)
        hills.move_to(0, ground.rect.top - hills.rect.height)

        mountain = Mountain()
        mountain.add_to(self)
        mountain.move_to(1300, ground.rect.top - mountain.rect.height)

        # Mountain platforms
        platform = Sprite("600ad/platform")
        self.main_layer.add(platform)
        platform.move_to(1740, mountain.rect.bottom - platform.rect.height - 10)

        platform = Sprite("600ad/platform")
        self.main_layer.add(platform)
        platform.move_to(1990, mountain.rect.bottom - platform.rect.height - 100)

        platform = Sprite("600ad/platform")
        self.main_layer.add(platform)
        platform.move_to(2240, mountain.rect.bottom - platform.rect.height - 180)

        platform = Sprite("600ad/platform")
        self.main_layer.add(platform)
        platform.move_to(1990, mountain.rect.bottom - platform.rect.height - 260)

        platform = Sprite("600ad/platform")
        self.main_layer.add(platform)
        platform.move_to(2240, mountain.rect.bottom - platform.rect.height - 340)

        platform = Sprite("600ad/platform")
        self.main_layer.add(platform)
        platform.move_to(1990, mountain.rect.bottom - platform.rect.height - 420)

        platform = Sprite("600ad/platform")
        self.main_layer.add(platform)
        platform.move_to(2240, mountain.rect.bottom - platform.rect.height - 500)
示例#8
0
    def setup(self):
        self.exploding = False
        self.exploded = False

        ground = TiledSprite("ground", self.size[0] / 32, 1)
        self.main_layer.add(ground)
        ground.move_to(0, self.size[1] - ground.rect.height)

        hills = Sprite("65000000bc/hills_1")
        self.bg_layer.add(hills)
        hills.move_to(0, ground.rect.top - hills.rect.height)

        # Volcano
        self.volcano = Volcano()
        self.volcano.add_to(self)
        self.volcano.move_to(1400, ground.rect.top - self.volcano.rect.height + 1)

        blocker = Box(150, self.size[1] - self.volcano.rect.height - 20, (0, 0, 0, 0))
        self.main_layer.add(blocker)
        blocker.move_to(self.volcano.lava_pool.rect.right - 100, 0)

        # Left-side lava pool
        lava_pool = TiledSprite("65000000bc/lava_pool", 5, 1)
        lava_pool.lethal = True
        self.main_layer.add(lava_pool)
        lava_pool.move_to(self.volcano.rect.left - lava_pool.rect.width - 100, ground.rect.top - 18)

        # Platforms
        platform = FloatingSprite("65000000bc/platform")
        self.main_layer.add(platform)
        platform.move_to(lava_pool.rect.left + 250, lava_pool.rect.top - 10)

        platform = FloatingSprite("65000000bc/platform")
        self.main_layer.add(platform)
        platform.move_to(lava_pool.rect.left + 500, lava_pool.rect.top - 8)

        platform = FloatingSprite("65000000bc/platform")
        self.main_layer.add(platform)
        platform.move_to(lava_pool.rect.left + 750, lava_pool.rect.top - 12)

        # Right-side lava pool
        lava_pool = TiledSprite("65000000bc/lava_pool", 3, 1)
        lava_pool.lethal = True
        self.main_layer.add(lava_pool)
        lava_pool.move_to(self.volcano.rect.right + 200, ground.rect.top - 18)

        # Dynamite explosion trigger
        explosion_box = EventBox(self)
        explosion_box.rects.append(
            pygame.Rect(
                self.volcano.lava_puddle.rect.x,
                self.volcano.lava_puddle.rect.bottom - 5,
                self.volcano.lava_puddle.rect.width,
                5,
            )
        )
        explosion_box.watch_object_moves(self.level.dynamite)
        explosion_box.object_entered.connect(self.on_dynamite_placed)

        # Artifact
        self.level.add_artifact(self, lava_pool.rect.right + 200, ground.rect.top)
示例#9
0
    def setup(self):
        area_width, area_height = self.size

        ground = Box(area_width, 60, (83, 107, 143))
        self.main_layer.add(ground)
        ground.move_to(0, area_height - ground.rect.height)

        ceiling = Box(area_width, 60, (83, 107, 143))
        self.main_layer.add(ceiling)
        ceiling.move_to(0, 0)

        wall_height = area_height - ground.rect.height - ceiling.rect.height + 2
        wall_y = ceiling.rect.bottom - 1

        left_wall = Box(60, wall_height, (83, 107, 143))
        self.main_layer.add(left_wall)
        left_wall.move_to(0, wall_y)

        right_wall = Box(60, wall_height, (83, 107, 143))
        self.main_layer.add(right_wall)
        right_wall.move_to(area_width - right_wall.rect.width, wall_y)

        self.main_layer.add(self.door)
        self.door.move_to(left_wall.rect.right + 100,
                          ground.rect.top - self.door.rect.height)
        self.door.destination = self.time_period.areas['default'].bluebox

        # Reverse gravity background
        reverse_grav_bg = Sprite('300ne/bluebox_reverse_gravity_bg')
        self.bg_layer.add(reverse_grav_bg)
        reverse_grav_bg.move_to(left_wall.rect.right, ceiling.rect.bottom)

        # Reverse gravity area
        gravity_eventbox = EventBox(self)
        gravity_eventbox.rects.append(reverse_grav_bg.rect)
        gravity_eventbox.watch_object_moves(self.level.engine.player)
        gravity_eventbox.object_entered.connect(
            lambda obj: obj.set_reverse_gravity(True))
        gravity_eventbox.object_exited.connect(
            lambda obj: obj.set_reverse_gravity(False))
        gravity_eventbox.object_moved.connect(
            lambda obj: obj.set_reverse_gravity(True))

        teleporter1 = BlueBoxTeleporter()
        self.main_layer.add(teleporter1)
        teleporter1.move_to(right_wall.rect.left - teleporter1.rect.width - 20,
                            ground.rect.top - teleporter1.rect.height)

        teleporter2 = BlueBoxTeleporter()
        teleporter2.reverse_gravity = True
        self.main_layer.add(teleporter2)
        teleporter2.move_to(left_wall.rect.right + 20, ceiling.rect.bottom)

        teleporter1.destination = teleporter2
        teleporter2.destination = teleporter1

        self.main_layer.add(self.level.triangle_key)
        self.level.triangle_key.move_to(
            right_wall.rect.left - self.level.triangle_key.rect.width - 40,
            ceiling.rect.bottom)
        self.level.triangle_key.set_reverse_gravity(True)
示例#10
0
    def setup(self):
        self.in_end_sequence = False

        level_width, level_height = self.size

        base_platforms_y = \
            self.start_pos[1] + self.engine.player.rect.height + 3

        # Left platforms
        platform = FloatingPlatform1NE()
        self.main_layer.add(platform)
        platform.move_to(233, base_platforms_y)

        platform = FloatingPlatform1NE()
        self.main_layer.add(platform)
        platform.move_to(0, 255)

        # Ceiling
        ceiling = Sprite('300ne/ceiling')
        self.main_layer.add(ceiling)
        ceiling.move_to(platform.rect.right + 80, 0)

        # Spikes
        spikes = Sprite('300ne/ceiling_spikes')
        spikes.lethal = True
        self.main_layer.add(spikes)
        spikes.move_to(ceiling.rect.left, ceiling.rect.bottom)

        # Reverse-gravity platforms
        for x, y in self.PLATFORM_POS:
            platform = FloatingSprite('300ne/small_platform')
            platform.set_reverse_gravity(True)
            self.main_layer.add(platform)
            platform.move_to(ceiling.rect.left + x,
                             ceiling.rect.top + y)

        # Reverse gravity background
        reverse_grav_bg = Sprite('300ne/reverse_gravity_bg')
        self.bg_layer.add(reverse_grav_bg)
        reverse_grav_bg.move_to(ceiling.rect.left, ceiling.rect.bottom)

        # Reverse gravity area
        gravity_eventbox = EventBox(self)
        gravity_eventbox.rects.append(reverse_grav_bg.rect)
        gravity_eventbox.watch_object_moves(self.level.engine.player)
        gravity_eventbox.object_entered.connect(
            lambda obj: obj.set_reverse_gravity(True))
        gravity_eventbox.object_exited.connect(
            lambda obj: obj.set_reverse_gravity(False))
        gravity_eventbox.object_moved.connect(
            lambda obj: obj.set_reverse_gravity(True))

        # Right-side floor
        floor = Sprite('300ne/floor')
        self.main_layer.add(floor)
        floor.move_to(level_width - floor.rect.width,
                      level_height - floor.rect.height)

        step = FloatingSprite('300ne/step')
        self.main_layer.add(step)
        step.move_to(floor.rect.left + 20,
                     floor.rect.top - step.rect.height - 40)

        monolith = Monolith300NE()
        self.main_layer.add(monolith)
        monolith.move_to(floor.rect.left + 200,
                         floor.rect.top - monolith.rect.height)

        # Container
        self.container_base = Sprite('300ne/container_base')
        self.main_layer.add(self.container_base)
        self.container_base.move_to(
            floor.rect.right - self.container_base.rect.width - 400,
            floor.rect.top - self.container_base.rect.height)

        self.container_bg = Sprite('300ne/container_bg')
        self.bg_layer.add(self.container_bg)
        self.container_bg.move_to(
            self.container_base.rect.left +
            (self.container_base.rect.width - self.container_bg.rect.width) / 2,
            self.container_base.rect.top - self.container_bg.rect.height)

        self.level.add_artifact(self, self.container_base.rect.centerx,
                                self.container_base.rect.top)

        self.container = Sprite('300ne/container')
        self.main_layer.add(self.container)
        self.container.move_to(self.container_bg.rect.left,
                               self.container_bg.rect.top)

        self.keyhole = Sprite('300ne/keyhole')
        self.main_layer.add(self.keyhole)
        self.keyhole.move_to(
            self.container.rect.right - self.keyhole.rect.width - 10,
            self.container.rect.bottom - self.keyhole.rect.height - 10)

        keyhole_eventbox = EventBox(self)
        keyhole_eventbox.rects.append(
            pygame.Rect(self.container.rect.right,
                        self.keyhole.rect.top,
                        40,
                        self.keyhole.rect.height))
        keyhole_eventbox.watch_object_moves(self.level.triangle_key)
        keyhole_eventbox.object_entered.connect(self.start_end_sequence)
示例#11
0
class Outside300NE(Level3OutsideArea):
    PLATFORM_POS = [
        (2, 83),
        (83, 180),
        (277, 238),
        (445, 163),
        (608, 186),
        (912, 272),
    ]

    def draw_bg(self, surface):
        surface.fill((200, 200, 200))

    def setup(self):
        self.in_end_sequence = False

        level_width, level_height = self.size

        base_platforms_y = \
            self.start_pos[1] + self.engine.player.rect.height + 3

        # Left platforms
        platform = FloatingPlatform1NE()
        self.main_layer.add(platform)
        platform.move_to(233, base_platforms_y)

        platform = FloatingPlatform1NE()
        self.main_layer.add(platform)
        platform.move_to(0, 255)

        # Ceiling
        ceiling = Sprite('300ne/ceiling')
        self.main_layer.add(ceiling)
        ceiling.move_to(platform.rect.right + 80, 0)

        # Spikes
        spikes = Sprite('300ne/ceiling_spikes')
        spikes.lethal = True
        self.main_layer.add(spikes)
        spikes.move_to(ceiling.rect.left, ceiling.rect.bottom)

        # Reverse-gravity platforms
        for x, y in self.PLATFORM_POS:
            platform = FloatingSprite('300ne/small_platform')
            platform.set_reverse_gravity(True)
            self.main_layer.add(platform)
            platform.move_to(ceiling.rect.left + x,
                             ceiling.rect.top + y)

        # Reverse gravity background
        reverse_grav_bg = Sprite('300ne/reverse_gravity_bg')
        self.bg_layer.add(reverse_grav_bg)
        reverse_grav_bg.move_to(ceiling.rect.left, ceiling.rect.bottom)

        # Reverse gravity area
        gravity_eventbox = EventBox(self)
        gravity_eventbox.rects.append(reverse_grav_bg.rect)
        gravity_eventbox.watch_object_moves(self.level.engine.player)
        gravity_eventbox.object_entered.connect(
            lambda obj: obj.set_reverse_gravity(True))
        gravity_eventbox.object_exited.connect(
            lambda obj: obj.set_reverse_gravity(False))
        gravity_eventbox.object_moved.connect(
            lambda obj: obj.set_reverse_gravity(True))

        # Right-side floor
        floor = Sprite('300ne/floor')
        self.main_layer.add(floor)
        floor.move_to(level_width - floor.rect.width,
                      level_height - floor.rect.height)

        step = FloatingSprite('300ne/step')
        self.main_layer.add(step)
        step.move_to(floor.rect.left + 20,
                     floor.rect.top - step.rect.height - 40)

        monolith = Monolith300NE()
        self.main_layer.add(monolith)
        monolith.move_to(floor.rect.left + 200,
                         floor.rect.top - monolith.rect.height)

        # Container
        self.container_base = Sprite('300ne/container_base')
        self.main_layer.add(self.container_base)
        self.container_base.move_to(
            floor.rect.right - self.container_base.rect.width - 400,
            floor.rect.top - self.container_base.rect.height)

        self.container_bg = Sprite('300ne/container_bg')
        self.bg_layer.add(self.container_bg)
        self.container_bg.move_to(
            self.container_base.rect.left +
            (self.container_base.rect.width - self.container_bg.rect.width) / 2,
            self.container_base.rect.top - self.container_bg.rect.height)

        self.level.add_artifact(self, self.container_base.rect.centerx,
                                self.container_base.rect.top)

        self.container = Sprite('300ne/container')
        self.main_layer.add(self.container)
        self.container.move_to(self.container_bg.rect.left,
                               self.container_bg.rect.top)

        self.keyhole = Sprite('300ne/keyhole')
        self.main_layer.add(self.keyhole)
        self.keyhole.move_to(
            self.container.rect.right - self.keyhole.rect.width - 10,
            self.container.rect.bottom - self.keyhole.rect.height - 10)

        keyhole_eventbox = EventBox(self)
        keyhole_eventbox.rects.append(
            pygame.Rect(self.container.rect.right,
                        self.keyhole.rect.top,
                        40,
                        self.keyhole.rect.height))
        keyhole_eventbox.watch_object_moves(self.level.triangle_key)
        keyhole_eventbox.object_entered.connect(self.start_end_sequence)


    def start_end_sequence(self, *args, **kwargs):
        if self.in_end_sequence:
            return

        self.in_end_sequence = True
        player = self.level.engine.player
        player.stop_tractor_beam()
        player.block_events = True
        player.velocity = (0, 0)
        player.fall()

        move_effect = MoveEffect(self.level.triangle_key)
        move_effect.total_time_ms = 1500
        move_effect.timer_ms = 30
        move_effect.destination = self.keyhole.rect.topleft
        move_effect.stopped.connect(self.on_key_inserted)
        move_effect.start()

    def on_key_inserted(self):
        self.level.triangle_key.remove()
        self.keyhole.remove()

        hide_effect = SlideHideEffect(self.container)
        hide_effect.direction = Direction.DOWN
        hide_effect.timer_ms = 30
        hide_effect.total_time_ms = 500
        hide_effect.stopped.connect(self.on_container_removed)
        hide_effect.start()

        hide_effect = SlideHideEffect(self.container_bg)
        hide_effect.direction = Direction.DOWN
        hide_effect.timer_ms = 30
        hide_effect.total_time_ms = 500
        hide_effect.start()

    def on_container_removed(self):
        self.container.collidable = False

        # Go collect the artifact!
        player = self.level.engine.player
        player.jump()

        timer = Timer(200, self.hop_onto_platform, one_shot=True)
        timer.start()

    def hop_onto_platform(self):
        player = self.level.engine.player
        player.velocity = (-player.MOVE_SPEED, player.velocity[1])
        timer = Timer(700, self.stop_moving, one_shot=True)
        timer.start()

    def stop_moving(self):
        timer = Timer(300, self.show_container, one_shot=True)
        timer.start()

    def show_container(self):
        player = self.level.engine.player
        player.velocity = (0, player.velocity[1])
        player.fall()

        show_effect = SlideShowEffect(self.container)
        show_effect.direction = Direction.UP
        show_effect.timer_ms = 30
        show_effect.total_time_ms = 500
        show_effect.stopped.connect(self.on_container_added)
        timer = Timer(700, show_effect.start, one_shot=True)
        timer.start()

    def on_container_added(self):
        player = self.level.engine.player
        self.questionmark = Sprite('questionmark')
        self.questionmark.collidable = False
        self.main_layer.add(self.questionmark)
        self.questionmark.move_to(
            player.rect.left +
            (player.rect.width - self.questionmark.rect.width) / 2,
            player.rect.top - self.questionmark.rect.height - 10)

        timer = Timer(300, self.hide_questionmark, one_shot=True)
        timer.start()

    def hide_questionmark(self):
        self.questionmark.remove()
        self.level.engine.player.direction = Direction.RIGHT

        timer = Timer(500, self.absorb_artifact, one_shot=True)
        timer.start()

    def absorb_artifact(self):
        player = self.level.engine.player
        player.direction = Direction.LEFT

        self.level.artifact.collidable = False

        move_effect = MoveEffect(self.level.artifact)
        move_effect.collidable = False
        move_effect.total_time_ms = 1500
        move_effect.timer_ms = 30
        move_effect.destination = player.rect.center
        move_effect.start()

        screen_flash_effect = ScreenFlashEffect(self.fg_layer,
                                                self.level.engine.camera.rect)
        screen_flash_effect.flash_peaked.connect(self.grow_probe)
        screen_flash_effect.stopped.connect(self.prepare_launch)
        screen_flash_effect.start()

    def grow_probe(self):
        bottom = self.container_bg.rect.bottom
        self.container_bg.name = '300ne/broken_container_bg'
        self.container_bg.update_image()
        self.container_bg.rect.bottom = bottom

        bottom = self.container.rect.bottom
        self.container.name = '300ne/broken_container'
        self.container.update_image()
        self.container.rect.bottom = bottom

        self.level.artifact.remove()
        self.level.engine.player.remove()

        self.large_probe = Sprite('probe_large')
        self.main_layer.add(self.large_probe)
        self.large_probe.collidable = False
        self.large_probe.obey_gravity = False
        self.large_probe.move_to(
            self.container.rect.left +
            (self.container.rect.width - self.large_probe.rect.width) / 2,
            self.container.rect.bottom - 2 * self.large_probe.rect.height)

        # We're going to force updates to get things in the right order.
        self.container.hide()
        self.container.show()
        self.container_base.hide()
        self.container_base.show()

    def prepare_launch(self):
        player = self.level.engine.player
        self.explosion = ExplosionParticleSystem(self)
        self.explosion.max_lifetime = 1
        self.explosion.min_lifetime = 0.5
        self.explosion.min_particles = 30
        self.explosion.max_particles = 40
        self.explosion.max_scale = 0.4
        self.explosion.min_angle = -(4 * math.pi) / 3
        self.explosion.max_angle = -(5 * math.pi) / 3
        self.explosion.repeat = True
        self.explosion.start(self.container.rect.centerx,
                             self.large_probe.rect.bottom)

        shake_effect = ShakeEffect(self.large_probe)
        shake_effect.start()

        timer = Timer(3000, self.launch_probe, one_shot=True)
        timer.start()

    def launch_probe(self):
        self.large_probe.velocity = (0, -15)
        self.large_probe.moved.connect(self.move_explosion)

        timer = Timer(4000, self.probe_launched, one_shot=True)
        timer.start()

    def move_explosion(self, dx, dy):
        self.explosion.pos = (self.container.rect.centerx,
                              self.large_probe.rect.bottom)

    def probe_launched(self):
        self.explosion.stop()
        screen_flash_effect = ScreenFadeEffect(self.fg_layer,
                                               self.level.engine.camera.rect)
        screen_flash_effect.fade_time_ms = 3000
        screen_flash_effect.stopped.connect(
            self.level.engine.show_end_scene)
        screen_flash_effect.start()
示例#12
0
    def setup(self):
        super(Pyramid2300AD, self).setup()

        # Fall to your doom, probes!
        self.pit.remove()

        wall = TiledSprite(self.wall_name, 4, 3)
        self.main_layer.add(wall)
        wall.move_to(*self.weapons_entrance_pos)

        self.main_layer.add(self.level.flamethrower)
        self.level.flamethrower.move_to(
            wall.rect.right + 100,
            wall.rect.bottom - self.level.flamethrower.rect.height)

        wall = TiledSprite(self.wall_name, 2, 7)
        self.main_layer.add(wall)
        wall.move_to(self.topleft_platform.rect.left,
                     self.topleft_platform.rect.top - wall.rect.height)

        wall = TiledSprite(self.wall_name, 2, 7)
        self.main_layer.add(wall)
        wall.move_to(self.topleft_platform.rect.right - wall.rect.width,
                     self.topleft_platform.rect.top - wall.rect.height)

        button = Button('2300ad/button')
        button.pressed.connect(self.on_platforms_button_pressed)
        self.main_layer.add(button)
        button.move_to(wall.rect.left - button.rect.width,
                       self.topleft_platform.rect.top - button.rect.height - 10)

        wall = TiledSprite(self.wall_name, 15, 6)
        self.main_layer.add(wall)
        wall.move_to(self.topleft_platform.rect.right - wall.rect.width,
                     button.rect.top - wall.rect.height - 10)

        sign = Sprite('2300ad/weapons_sign')
        self.main_layer.add(sign)
        sign.move_to(button.rect.right - sign.rect.width,
                     wall.rect.bottom - sign.rect.height - 20)

        step = TiledSprite(self.wall_name, 2, 6)
        self.main_layer.add(step)
        step.move_to(self.pit.rect.left - step.rect.width,
                     self.ground_top - step.rect.height)
        x = step.rect.left

        step = TiledSprite(self.wall_name, 2, 4)
        self.main_layer.add(step)
        step.move_to(x - step.rect.width, self.ground_top - step.rect.height)
        x = step.rect.left

        step = TiledSprite(self.wall_name, 2, 2)
        self.main_layer.add(step)
        step.move_to(x - step.rect.width, self.ground_top - step.rect.height)

        platform_x = self.pit.rect.left
        platform_y = self.pit.rect.top - 500

        for x, y in self.PLATFORM_POS:
            platform = TogglePlatform()
            self.main_layer.add(platform)
            platform.move_to(platform_x + x, platform_y + y)
            self.platforms.append(platform)
示例#13
0
    def setup(self):
        level_width, level_height = self.size

        ground = TiledSprite('12000bc/ground', 3, 1)
        self.main_layer.add(ground)
        ground.move_to(0, level_height - ground.rect.height)
        x = ground.rect.right + 800

        tiles_x = (self.size[0] - x) / 144
        ground = TiledSprite('12000bc/ground', tiles_x, 1)
        self.main_layer.add(ground)
        ground.move_to(x, level_height - ground.rect.height)

        ice_hill = Sprite('12000bc/ice_hill_left')
        self.main_layer.add(ice_hill)
        ice_hill.use_pixel_collisions = True
        ice_hill.move_to(0, ground.rect.top - ice_hill.rect.height + 18)

        ice_hill = Sprite('12000bc/ice_hill_right')
        self.main_layer.add(ice_hill)
        ice_hill.use_pixel_collisions = True
        ice_hill.move_to(level_width - ice_hill.rect.width,
                         ground.rect.top - ice_hill.rect.height + 18)

        hill_bg = Sprite('12000bc/hill_bg')
        self.bg_layer.add(hill_bg)
        hill_bg.move_to(ice_hill.rect.right,
                        ground.rect.top - hill_bg.rect.height)

        hill_bg = Sprite('12000bc/hill_bg')
        self.bg_layer.add(hill_bg)
        hill_bg.move_to(ground.rect.left + 600,
                        ground.rect.top - hill_bg.rect.height)

        hill_bg = Sprite('12000bc/hill_bg')
        self.bg_layer.add(hill_bg)
        hill_bg.move_to(ground.rect.left + 2000,
                        ground.rect.top - hill_bg.rect.height)

        self.ice_boulder = IceBoulder()
        self.main_layer.add(self.ice_boulder)
        self.ice_boulder.move_to(
            2315, ground.rect.top - self.ice_boulder.rect.height)
示例#14
0
    def setup(self):
        level_width, level_height = self.size

        # Ground
        tiles_x = self.size[0] / 32
        ground = TiledSprite('ground', tiles_x, 1)
        self.main_layer.add(ground)
        ground.move_to(0, self.size[1] - ground.rect.height)

        building_rect = self.BUILDING_RECT.move(
            0, ground.rect.top - self.BUILDING_RECT.height)

        # Building background
        building_bg = Box(*building_rect.size)
        self.bg_layer.add(building_bg)
        building_bg.move_to(*building_rect.topleft)

        # First floor
        floor1 = Box(building_rect.width, self.GROUND_HEIGHT, self.FLOOR_COLOR)
        self.main_layer.add(floor1)
        floor1.move_to(building_rect.left, ground.rect.top)

        # Second floor
        floor2 = Box(building_rect.width, self.GROUND_HEIGHT, self.FLOOR_COLOR)
        self.main_layer.add(floor2)
        floor2.move_to(building_rect.left,
                       building_rect.top +
                       (building_rect.height - floor2.rect.height) / 2)

        # Left wall of building
        box = Box(self.WALL_WIDTH, building_rect.height, self.WALL_COLOR)
        self.main_layer.add(box)
        box.move_to(building_rect.left, building_rect.top)

        # Right wall of the building
        right_wall = Box(self.WALL_WIDTH, building_rect.height, self.WALL_COLOR)
        self.main_layer.add(right_wall)
        right_wall.move_to(building_rect.right - self.WALL_WIDTH,
                           building_rect.top)

        # Ceiling
        box = Box(building_rect.width, self.GROUND_HEIGHT)
        self.main_layer.add(box)
        box.move_to(building_rect.left, building_rect.top)

        # Top elevator
        elevator1 = Elevator()
        self.main_layer.add(elevator1)
        elevator1.move_to(building_rect.left + 100,
                          building_rect.top - elevator1.rect.height)

        # Bottom elevator
        elevator2 = Elevator()
        self.main_layer.add(elevator2)
        elevator2.move_to(elevator1.rect.left,
                          floor2.rect.top - elevator2.rect.height)

        # Link up the elevators
        elevator1.destination = elevator2
        elevator2.destination = elevator1

        # Dynamite
        self.main_layer.add(self.level.dynamite)
        self.level.dynamite.move_to(
            right_wall.rect.left - self.level.dynamite.rect.width - 20,
            floor2.rect.top - self.level.dynamite.rect.height)
        #self.level.dynamite.move_to(
        #    200, ground.rect.top - self.level.dynamite.rect.height)

        # Mountain
        mountain = Mountain()
        mountain.add_to(self)
        mountain.move_to(1300, ground.rect.top - mountain.rect.height)

        platform = Sprite('1999ad/lavamatics_platform')
        self.main_layer.add(platform)
        platform.move_to(1841,
                         mountain.rect.bottom - platform.rect.height - 500)

        platform = Sprite('1999ad/l_tube')
        self.main_layer.add(platform)
        platform.move_to(2140,
                         mountain.rect.bottom - platform.rect.height - 450)
示例#15
0
    def setup(self):
        tiles_x = self.size[0] / 32
        ground = TiledSprite('ground', tiles_x, 1)
        self.main_layer.add(ground)
        ground.move_to(0, self.size[1] - ground.rect.height)

        hills = Sprite('600ad/hills_1')
        self.bg_layer.add(hills)
        hills.move_to(0, ground.rect.top - hills.rect.height)

        mountain = Mountain()
        mountain.add_to(self)
        mountain.move_to(1300, ground.rect.top - mountain.rect.height)

        # Mountain platforms
        platform = Sprite('600ad/platform')
        self.main_layer.add(platform)
        platform.move_to(1740,
                         mountain.rect.bottom - platform.rect.height - 10)

        platform = Sprite('600ad/platform')
        self.main_layer.add(platform)
        platform.move_to(1990,
                         mountain.rect.bottom - platform.rect.height - 100)

        platform = Sprite('600ad/platform')
        self.main_layer.add(platform)
        platform.move_to(2240,
                         mountain.rect.bottom - platform.rect.height - 180)

        platform = Sprite('600ad/platform')
        self.main_layer.add(platform)
        platform.move_to(1990,
                         mountain.rect.bottom - platform.rect.height - 260)

        platform = Sprite('600ad/platform')
        self.main_layer.add(platform)
        platform.move_to(2240,
                         mountain.rect.bottom - platform.rect.height - 340)

        platform = Sprite('600ad/platform')
        self.main_layer.add(platform)
        platform.move_to(1990,
                         mountain.rect.bottom - platform.rect.height - 420)

        platform = Sprite('600ad/platform')
        self.main_layer.add(platform)
        platform.move_to(2240,
                         mountain.rect.bottom - platform.rect.height - 500)
示例#16
0
    def setup(self):
        self.exploding = False
        self.exploded = False

        ground = TiledSprite('ground', self.size[0] / 32, 1)
        self.main_layer.add(ground)
        ground.move_to(0, self.size[1] - ground.rect.height)

        hills = Sprite('65000000bc/hills_1')
        self.bg_layer.add(hills)
        hills.move_to(0, ground.rect.top - hills.rect.height)

        # Volcano
        self.volcano = Volcano()
        self.volcano.add_to(self)
        self.volcano.move_to(
            1400, ground.rect.top - self.volcano.rect.height + 1)

        blocker = Box(150, self.size[1] - self.volcano.rect.height - 20,
                      (0, 0, 0, 0))
        self.main_layer.add(blocker)
        blocker.move_to(self.volcano.lava_pool.rect.right - 100, 0)

        # Left-side lava pool
        lava_pool = TiledSprite('65000000bc/lava_pool', 5, 1)
        lava_pool.lethal = True
        self.main_layer.add(lava_pool)
        lava_pool.move_to(self.volcano.rect.left - lava_pool.rect.width - 100,
                          ground.rect.top - 18)

        # Platforms
        platform = FloatingSprite('65000000bc/platform')
        self.main_layer.add(platform)
        platform.move_to(lava_pool.rect.left + 250, lava_pool.rect.top - 10)

        platform = FloatingSprite('65000000bc/platform')
        self.main_layer.add(platform)
        platform.move_to(lava_pool.rect.left + 500, lava_pool.rect.top - 8)

        platform = FloatingSprite('65000000bc/platform')
        self.main_layer.add(platform)
        platform.move_to(lava_pool.rect.left + 750, lava_pool.rect.top - 12)

        # Right-side lava pool
        lava_pool = TiledSprite('65000000bc/lava_pool', 3, 1)
        lava_pool.lethal = True
        self.main_layer.add(lava_pool)
        lava_pool.move_to(self.volcano.rect.right + 200,
                          ground.rect.top - 18)

        # Dynamite explosion trigger
        explosion_box = EventBox(self)
        explosion_box.rects.append(
            pygame.Rect(self.volcano.lava_puddle.rect.x,
                        self.volcano.lava_puddle.rect.bottom - 5,
                        self.volcano.lava_puddle.rect.width,
                        5))
        explosion_box.watch_object_moves(self.level.dynamite)
        explosion_box.object_entered.connect(self.on_dynamite_placed)

        # Artifact
        self.level.add_artifact(self, lava_pool.rect.right + 200,
                                ground.rect.top)