Example #1
0
    def add_rotating_platform(self,
                              position,
                              radius=2,
                              platform_width=1,
                              T=600,
                              color=(50, 50, 50)):

        height = 10 * S
        R = radius * box_size * 2
        width = platform_width * box_size * 2
        # top will be at same level as floor for position[1] = 0
        pos = np.array(position, dtype='float') * (box_size * 2.0) + [
            0, floor + height
        ]
        path = [
            np.array([
                pos[0] + R * math.cos(2 * math.pi * x / T),
                pos[1] + R * math.sin(2 * math.pi * x / T)
            ]) for x in range(T)
        ]
        self.master_platform_list.append(
            Platform.Moving_Platform([width, height],
                                     copy.copy(path),
                                     color=color))
        self.master_platform_list.append(
            Platform.Moving_Platform([width, height],
                                     path[int(T / 2):] + path[:int(T / 2)],
                                     color=color))

        self.background_list.append(Platform.Platform(pos, [height, height]))
Example #2
0
    def __init__(self, player):
        """ Create level 1. """

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

        self.background = pygame.image.load("background_01.png").convert()
        self.background.set_colorkey(constants.WHITE)
        self.level_limit = -2500

        # Array with type of platform, and x, y location of the platform.
        level = [[500, 500, Platform.GRASS_LEFT]]

        # Go through the array above and add platforms
        for platform in level:
            block = Platform.Platform(platform[0], platform[1], platform[2],
                                      "tiles_spritesheet.png")
            block.player = self.player
            self.platform_list.add(block)

        # Add a custom moving platform
        block = Platform.Moving_Platform(1350, 280,
                                         Platform.STONE_PLATFORM_MIDDLE,
                                         "tiles_spritesheet.png")
        block.boundary_left = 1350
        block.boundary_right = 1600
        block.change_x = 1
        block.player = self.player
        block.level = self
        self.platform_list.add(block)