def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.level_limit = -1000 # Array with type of platform, and x, y location of the platform. level = [ [210, 70, 500, 550], [210, 70, 800, 400], [210, 70, 1000, 500], [210, 70, 1120, 280], ] # Go through the array above and add platforms for platform in level: block = Platform(platform[0], platform[1]) block.rect.x = platform[2] block.rect.y = platform[3] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = MovingPlatform(70, 70) block.rect.x = 1500 block.rect.y = 300 block.boundary_top = 100 block.boundary_bottom = 550 block.change_y = -1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.level_limit = -1500 # Array with width, height, x, and y of platform level = [ [210, 70, 500, 500], [210, 70, 800, 400], [210, 70, 1000, 500], [210, 70, 1120, 280], ] # Go through the array above and add platforms for platform in level: block = Platform(platform[0], platform[1]) block.rect.x = platform[2] block.rect.y = platform[3] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = MovingPlatform(70, 40) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block)
def __init__(self, player): """ Create level 1. """ # Call the parent constructor Level.__init__(self, player) self.level_limit = -6000 BLOCK_WIDTH = 210 self.block_height = 70 # Array with width, height, x, and y of platform level = [ [BLOCK_WIDTH, BLOCK_HEIGHT, 500, 500], [BLOCK_WIDTH, BLOCK_HEIGHT, 800, 400], [BLOCK_WIDTH, BLOCK_HEIGHT, 1000, 500], [BLOCK_WIDTH, BLOCK_HEIGHT, 1120, 280], [BLOCK_WIDTH, BLOCK_HEIGHT, 1500, 280], [BLOCK_WIDTH, BLOCK_HEIGHT, 2000, 280], [BLOCK_WIDTH, BLOCK_HEIGHT, 2500, 280], [BLOCK_WIDTH, BLOCK_HEIGHT, 3000, 280], [BLOCK_WIDTH, BLOCK_HEIGHT, 3500, 280], [BLOCK_WIDTH, BLOCK_HEIGHT, 4000, 280], [BLOCK_WIDTH, BLOCK_HEIGHT, 4500, 280], [BLOCK_WIDTH, BLOCK_HEIGHT, 5000, 280], [BLOCK_WIDTH, BLOCK_HEIGHT, 5500, 280], [BLOCK_WIDTH, BLOCK_HEIGHT, 60000, 280], ] # Go through the array above and add platforms for platform in level: block = Platform(platform[0], platform[1]) block.rect.x = platform[2] block.rect.y = platform[3] block.player = self.player self.platform_list.add(block) # Add a custom moving platform block = MovingPlatform(70, 40) block.rect.x = 1350 block.rect.y = 280 block.boundary_left = 1350 block.boundary_right = 1600 block.change_x = 1 block.player = self.player block.level = self self.platform_list.add(block) # Add a custom enemy enemy = Enemy(30, 30) enemy.rect.x = 900 enemy.rect.y = 300 enemy.boundary_left = 800 enemy.boundary_right = 1000 enemy.change_x = 1 enemy.player = self.player enemy.level = self self.enemy_list.add(enemy)
def __init__(self, player): # Call the parent constructor Level.__init__(self, player) # Jump over 29 platforms self.level_limit = -30950 # Functions and vars to compute the platforms. width = [] platforms = 30 width.append( random.randrange(Global_vars.SCREEN_WIDTH - 200, Global_vars.SCREEN_WIDTH + 400)) gap = random.randrange(120, Global_vars.player_jump_length + 100) height = Global_vars.SCREEN_HEIGHT - 200 platform_level = [[width[0], height, 0, 450]] i = 0 while platforms > 0: if platforms > 0: width.append( random.randrange(Global_vars.SCREEN_WIDTH - 200, Global_vars.SCREEN_WIDTH + 400)) if len(width) > 2: x += width[i] + gap else: x = width[i] + gap y = random.randrange(height, height + 50) if x <= width[i]: x += Global_vars.player_jump_length platform_level.append([width[-1], height, x, y]) platforms -= 1 i += 1 # Go through the array above and add playforms for platform in platform_level: block = Platform(platform[0], platform[1]) block.rect.x = platform[2] block.rect.y = platform[3] block.player = self.player self.platform_list.add(block)
def __init__(self, player): # Call the parent constructor Level.__init__(self, player) self.level_limit = -1000 # Array with the width, height, x, and y of platform platforms = 4 width = [] width.append(random.randrange(Global_vars.SCREEN_WIDTH - 200, Global_vars.SCREEN_WIDTH + 400)) height = Global_vars.SCREEN_HEIGHT - 200 platform_level = [[width[0], height, 0, 450]] i = 0 while platforms > 0: if platforms > 0: width.append(random.randrange(Global_vars.SCREEN_WIDTH - 200, Global_vars.SCREEN_WIDTH + 400)) gap = random.randrange(120, Global_vars.player_jump_length) if len(width) > 2: x += width[i] + gap else: x = width[i] + gap y = random.randrange(height, height + 50) if x <= width[i]: x += Global_vars.player_jump_length platform_level.append([width[-1], height, x, y]) platforms -= 1 i += 1 # Go through the array above and add playforms for platform in platform_level: block = Platform(platform[0], platform[1]) block.rect.x = platform[2] block.rect.y = platform[3] block.player = self.player self.platform_list.add(block)