Ejemplo n.º 1
0
    def __init__(self):
        self.bg_sprite = Sprite('mountain_bg')

        self.cover_sprite = Sprite('mountain_cover')
        self.cover_sprite.collidable = False

        self.bottom_sprite = Sprite('mountain_bottom')
        self.bottom_sprite.use_pixel_collisions = True
        self.bottom_sprite.update_image()

        self.top_sprite = Sprite('mountain_top')
        self.top_sprite.use_pixel_collisions = True
        self.top_sprite.update_image()

        self.left_sprites = []
        self.right_sprites = []

        for i in range(1, 6):
            sprite = Sprite('mountain_left_%s' % i)

            if i != 3:
                # Sort of a hack. We need a blocker so you can't
                # climb the mountain.
                sprite.use_pixel_collisions = True

            sprite.update_image()
            self.left_sprites.append(sprite)

            sprite = Sprite('mountain_right_%s' % i)
            sprite.use_pixel_collisions = True
            sprite.update_image()
            self.right_sprites.append(sprite)

        self.rect = pygame.Rect(
            0, 0, self.bottom_sprite.rect.width,
            sum([sprite.rect.height for sprite in self.right_sprites]) +
            self.top_sprite.rect.height + self.bottom_sprite.rect.height)
Ejemplo n.º 2
0
    def __init__(self):
        self.bg_sprite = Sprite('mountain_bg')

        self.cover_sprite = Sprite('mountain_cover')
        self.cover_sprite.collidable = False

        self.bottom_sprite = Sprite('mountain_bottom')
        self.bottom_sprite.use_pixel_collisions = True
        self.bottom_sprite.update_image()

        self.top_sprite = Sprite('mountain_top')
        self.top_sprite.use_pixel_collisions = True
        self.top_sprite.update_image()

        self.left_sprites = []
        self.right_sprites = []

        for i in range(1, 6):
            sprite = Sprite('mountain_left_%s' % i)

            if i != 3:
                # Sort of a hack. We need a blocker so you can't
                # climb the mountain.
                sprite.use_pixel_collisions = True

            sprite.update_image()
            self.left_sprites.append(sprite)

            sprite = Sprite('mountain_right_%s' % i)
            sprite.use_pixel_collisions = True
            sprite.update_image()
            self.right_sprites.append(sprite)

        self.rect = pygame.Rect(
            0, 0, self.bottom_sprite.rect.width,
            sum([sprite.rect.height for sprite in self.right_sprites]) +
            self.top_sprite.rect.height + self.bottom_sprite.rect.height)
Ejemplo n.º 3
0
class Volcano(object):
    BASE_CAVERN_RECT = pygame.Rect(0, 310, 600, 57)

    def __init__(self):
        self.lava_pool = TiledSprite('65000000bc/lava_pool', 4, 1)
        self.lava_pool.lethal = True

        self.lava_puddle = Sprite('65000000bc/volcano_lava_puddle')
        self.lava_puddle.collidable = False

        self.lava_puddle_blocker = Box(10, self.BASE_CAVERN_RECT.height,
                                       (0, 0, 0))

        self.top_sprite = Sprite('65000000bc/volcano_top')
        self.top_sprite.use_pixel_collisions = True
        self.top_sprite.update_image()

        self.bottom_sprite = Sprite('65000000bc/volcano_bottom')
        self.bottom_sprite.update_image()

        self.cavern_blocker = Box(self.bottom_sprite.rect.width / 2,
                                  self.BASE_CAVERN_RECT.height, (0, 0, 0))

        self.column_sprite = Sprite('65000000bc/volcano_column')
        self.column_sprite.use_pixel_collisions = True
        self.column_sprite.update_image()

        self.cover_sprite = Sprite('65000000bc/volcano_cover')
        self.cover_sprite.collidable = False

        self.rect = pygame.Rect(0, 0, self.bottom_sprite.rect.width,
                                self.top_sprite.rect.height +
                                self.BASE_CAVERN_RECT.height +
                                self.bottom_sprite.rect.height)

    def add_to(self, area):
        self.eventbox = EventBox(area)
        self.eventbox.object_entered.connect(
            lambda x: self.cover_sprite.hide())
        self.eventbox.object_exited.connect(
            lambda x: self.cover_sprite.show())
        self.eventbox.watch_object_moves(area.engine.player)

        area.main_layer.add(self.lava_puddle_blocker)
        area.main_layer.add(self.cavern_blocker)
        area.main_layer.add(self.lava_puddle)
        area.main_layer.add(self.lava_pool)
        area.main_layer.add(self.top_sprite)
        area.main_layer.add(self.bottom_sprite)
        area.main_layer.add(self.column_sprite)
        area.fg_layer.add(self.cover_sprite)

    def move_to(self, x, y):
        self.rect.left = x
        self.rect.top = y

        self.lava_pool.move_to(x + 360, y + 10)
        self.top_sprite.move_to(x, y)
        self.column_sprite.move_to(
            x + 578, y + self.rect.height - self.column_sprite.rect.height)
        self.bottom_sprite.move_to(
            x, y + self.rect.height - self.bottom_sprite.rect.height)
        self.lava_puddle.move_to(
            x + 574,
            self.bottom_sprite.rect.top - self.lava_puddle.rect.height + 4)
        self.lava_puddle_blocker.move_to(
            self.lava_puddle.rect.right - 10,
            self.lava_puddle.rect.bottom - self.lava_puddle_blocker.rect.height)
        self.cavern_blocker.move_to(
            self.column_sprite.rect.right,
            self.bottom_sprite.rect.top - self.cavern_blocker.rect.height)
        self.cover_sprite.move_to(
            x, y + self.rect.height - self.cover_sprite.rect.height)

        self.eventbox.rects.append(
            pygame.Rect(x, y + self.BASE_CAVERN_RECT.top,
                        self.rect.width, self.BASE_CAVERN_RECT.height))
        self.eventbox.rects.append(self.column_sprite.rect)

    def clear_passage(self):
        self.column_sprite.remove()
        self.lava_puddle.remove()
        self.lava_puddle_blocker.remove()
        self.cavern_blocker.remove()
Ejemplo n.º 4
0
class Mountain(object):
    LEFT_OFFSETS = [0, 90, 189, 239, 313]
    RIGHT_OFFSETS = [1427, 1236, 1208, 1121, 940]

    def __init__(self):
        self.bg_sprite = Sprite('mountain_bg')

        self.cover_sprite = Sprite('mountain_cover')
        self.cover_sprite.collidable = False

        self.bottom_sprite = Sprite('mountain_bottom')
        self.bottom_sprite.use_pixel_collisions = True
        self.bottom_sprite.update_image()

        self.top_sprite = Sprite('mountain_top')
        self.top_sprite.use_pixel_collisions = True
        self.top_sprite.update_image()

        self.left_sprites = []
        self.right_sprites = []

        for i in range(1, 6):
            sprite = Sprite('mountain_left_%s' % i)

            if i != 3:
                # Sort of a hack. We need a blocker so you can't
                # climb the mountain.
                sprite.use_pixel_collisions = True

            sprite.update_image()
            self.left_sprites.append(sprite)

            sprite = Sprite('mountain_right_%s' % i)
            sprite.use_pixel_collisions = True
            sprite.update_image()
            self.right_sprites.append(sprite)

        self.rect = pygame.Rect(
            0, 0, self.bottom_sprite.rect.width,
            sum([sprite.rect.height for sprite in self.right_sprites]) +
            self.top_sprite.rect.height + self.bottom_sprite.rect.height)

    def add_to(self, area):
        area.bg_layer.add(self.bg_sprite)
        area.main_layer.add(self.bottom_sprite)
        area.main_layer.add(self.top_sprite)
        area.fg_layer.add(self.cover_sprite)

        for sprite in self.left_sprites:
            area.main_layer.add(sprite)

        for sprite in self.right_sprites:
            area.main_layer.add(sprite)

        self.cave_eventbox = EventBox(area)
        self.cave_eventbox.object_moved.connect(
            self.on_cave_eventbox_moved)
        self.cave_eventbox.watch_object_moves(area.engine.player)

        self.floor_eventbox = EventBox(area)
        self.floor_eventbox.object_entered.connect(
            lambda x: self.cover_sprite.hide())
        self.floor_eventbox.watch_object_moves(area.engine.player)

    def move_to(self, x, y):
        self.rect.left = x
        self.rect.top = y

        self.cover_sprite.move_to(x, y)
        self.bg_sprite.move_to(x, y)
        self.top_sprite.move_to(x + 485, y)
        self.bottom_sprite.move_to(
            x, y + self.rect.height - self.bottom_sprite.rect.height)

        new_y = self.bottom_sprite.rect.top

        for i, sprite in enumerate(self.left_sprites):
            new_y = new_y - sprite.rect.height
            sprite.move_to(x + self.LEFT_OFFSETS[i], new_y)

        new_y = self.bottom_sprite.rect.top

        for i, sprite in enumerate(self.right_sprites):
            new_y = new_y - sprite.rect.height
            sprite.move_to(x + self.RIGHT_OFFSETS[i], new_y)

        self.cave_eventbox.rects.append(
            pygame.Rect(x + 382, y + 110, 157, 110))
        self.floor_eventbox.rects.append(
            pygame.Rect(x + 30, self.bottom_sprite.rect.top - 30,
                        self.rect.width - 60, 30))

    def on_cave_eventbox_moved(self, player):
        if player.rect.centerx <= self.cave_eventbox.rects[0].centerx:
            self.cover_sprite.show()
        else:
            self.cover_sprite.hide()
Ejemplo n.º 5
0
class Mountain(object):
    LEFT_OFFSETS = [0, 90, 189, 239, 313]
    RIGHT_OFFSETS = [1427, 1236, 1208, 1121, 940]

    def __init__(self):
        self.bg_sprite = Sprite('mountain_bg')

        self.cover_sprite = Sprite('mountain_cover')
        self.cover_sprite.collidable = False

        self.bottom_sprite = Sprite('mountain_bottom')
        self.bottom_sprite.use_pixel_collisions = True
        self.bottom_sprite.update_image()

        self.top_sprite = Sprite('mountain_top')
        self.top_sprite.use_pixel_collisions = True
        self.top_sprite.update_image()

        self.left_sprites = []
        self.right_sprites = []

        for i in range(1, 6):
            sprite = Sprite('mountain_left_%s' % i)

            if i != 3:
                # Sort of a hack. We need a blocker so you can't
                # climb the mountain.
                sprite.use_pixel_collisions = True

            sprite.update_image()
            self.left_sprites.append(sprite)

            sprite = Sprite('mountain_right_%s' % i)
            sprite.use_pixel_collisions = True
            sprite.update_image()
            self.right_sprites.append(sprite)

        self.rect = pygame.Rect(
            0, 0, self.bottom_sprite.rect.width,
            sum([sprite.rect.height for sprite in self.right_sprites]) +
            self.top_sprite.rect.height + self.bottom_sprite.rect.height)

    def add_to(self, area):
        area.bg_layer.add(self.bg_sprite)
        area.main_layer.add(self.bottom_sprite)
        area.main_layer.add(self.top_sprite)
        area.fg_layer.add(self.cover_sprite)

        for sprite in self.left_sprites:
            area.main_layer.add(sprite)

        for sprite in self.right_sprites:
            area.main_layer.add(sprite)

        self.cave_eventbox = EventBox(area)
        self.cave_eventbox.object_moved.connect(self.on_cave_eventbox_moved)
        self.cave_eventbox.watch_object_moves(area.engine.player)

        self.floor_eventbox = EventBox(area)
        self.floor_eventbox.object_entered.connect(
            lambda x: self.cover_sprite.hide())
        self.floor_eventbox.watch_object_moves(area.engine.player)

    def move_to(self, x, y):
        self.rect.left = x
        self.rect.top = y

        self.cover_sprite.move_to(x, y)
        self.bg_sprite.move_to(x, y)
        self.top_sprite.move_to(x + 485, y)
        self.bottom_sprite.move_to(
            x, y + self.rect.height - self.bottom_sprite.rect.height)

        new_y = self.bottom_sprite.rect.top

        for i, sprite in enumerate(self.left_sprites):
            new_y = new_y - sprite.rect.height
            sprite.move_to(x + self.LEFT_OFFSETS[i], new_y)

        new_y = self.bottom_sprite.rect.top

        for i, sprite in enumerate(self.right_sprites):
            new_y = new_y - sprite.rect.height
            sprite.move_to(x + self.RIGHT_OFFSETS[i], new_y)

        self.cave_eventbox.rects.append(pygame.Rect(x + 382, y + 110, 157,
                                                    110))
        self.floor_eventbox.rects.append(
            pygame.Rect(x + 30, self.bottom_sprite.rect.top - 30,
                        self.rect.width - 60, 30))

    def on_cave_eventbox_moved(self, player):
        if player.rect.centerx <= self.cave_eventbox.rects[0].centerx:
            self.cover_sprite.show()
        else:
            self.cover_sprite.hide()