Пример #1
0
    def start_explosion(self):
        self.detonate_timer.stop()
        self.detonate_timer = None

        self.level.dynamite.remove()
        self.level.dynamite = None

        self.explosion = ExplosionParticleSystem(self)
        self.explosion.start(2040, 1500)

        self.explosion_timer = Timer(350, self.on_explosion_done)
        self.explosion_timer.start()
Пример #2
0
    def start_explosion(self):
        self.detonate_timer.stop()
        self.detonate_timer = None

        self.level.dynamite.remove()
        self.level.dynamite = None

        self.explosion = ExplosionParticleSystem(self)
        self.explosion.start(2040, 1500)

        self.explosion_timer = Timer(350, self.on_explosion_done)
        self.explosion_timer.start()
Пример #3
0
    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()
Пример #4
0
class Outside65000000BC(Level1Area):
    def draw_bg(self, surface):
        surface.fill((0, 0, 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)

    def on_dynamite_placed(self, obj):
        assert obj == self.level.dynamite

        if self.exploding or self.exploded:
            return

        self.level.dynamite.light()
        self.exploding = True

        self.detonate_timer = Timer(1000, self.start_explosion)

    def start_explosion(self):
        self.detonate_timer.stop()
        self.detonate_timer = None

        self.level.dynamite.remove()
        self.level.dynamite = None

        self.explosion = ExplosionParticleSystem(self)
        self.explosion.start(2040, 1500)

        self.explosion_timer = Timer(350, self.on_explosion_done)
        self.explosion_timer.start()

    def on_explosion_done(self):
        self.explosion_timer.stop()
        self.explosion_timer = None
        self.exploding = False
        self.exploded = True
        self.volcano.clear_passage()
Пример #5
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()
Пример #6
0
class Outside65000000BC(Level1Area):
    def draw_bg(self, surface):
        surface.fill((0, 0, 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)

    def on_dynamite_placed(self, obj):
        assert obj == self.level.dynamite

        if self.exploding or self.exploded:
            return

        self.level.dynamite.light()
        self.exploding = True

        self.detonate_timer = Timer(1000, self.start_explosion)

    def start_explosion(self):
        self.detonate_timer.stop()
        self.detonate_timer = None

        self.level.dynamite.remove()
        self.level.dynamite = None

        self.explosion = ExplosionParticleSystem(self)
        self.explosion.start(2040, 1500)

        self.explosion_timer = Timer(350, self.on_explosion_done)
        self.explosion_timer.start()

    def on_explosion_done(self):
        self.explosion_timer.stop()
        self.explosion_timer = None
        self.exploding = False
        self.exploded = True
        self.volcano.clear_passage()