예제 #1
0
 def __init__(self, player):
     '''call parent constructor'''
     Level.__init__(self, player)
     self.level_limit = -10000
     '''array with with width, height, x, and y of platform'''
     level = [
         [210, 70, 500, 500],
         [210, 70, 800, 400],
         [210, 70, 1120, 280],
         [210, 70, 2000, 300],
         [210, 70, 1800, 500],
         [210, 70, 2900, 400],
     ]
     walls = [[70, 600, 0, 0], [70, 600, 3200, 0]]
     '''go through the array 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)
     '''do the same for level walls'''
     for wall in walls:
         block = Wall(wall[0], wall[1])
         block.rect.x = wall[2]
         block.rect.y = wall[3]
         block.player = self.player
         self.walls_list.add(block)
     '''add enemies to level'''
     self.enemy_list.add(Enemy())
     self.enemy_list.add(Enemy())
예제 #2
0
    def __init__(self, player):
        teleporter = Teleporter()
        # Call the parent constructor
        Level.__init__(self, player)

        self.level_limit = 1500

        # Array with type of platform, and x, y location of the platform.
        level = [
            [210, 70, 450, 770],
            [210, 70, 850, 520],
            [210, 70, 1000, 420],
            [210, 70, 1120, 580],
        ]

        # 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)
        teleporter.rect.x = self.level_limit
        teleporter.rect.y = 50
        self.teleporter_list.add(teleporter)
예제 #3
0
 def __init__(self, player):
     teleporter = Teleporter()
     # Call the parent constructor
     Level.__init__(self, player)
     self.level_limit = 2000
     # Array with width, height, x, and y of platform
     level = [[210, 40, 500, 650], [210, 40, 900, 600],
              [210, 40, 1200, 550], [210, 40, 1400, 450],
              [1000, 40, 2010, 795], [1000, 40, 2010, 795]]
     # 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)
         teleporter.rect.x = 1000
         teleporter.rect.y = 620
         self.teleporter_list.add(teleporter)
     # X and Y coordinates for generating enemies
     enemy_list = []
     enemy_level = [[230, 420], [500, 420], [800, 300]]
     for n in enemy_level:
         enemy = Enemy()
         enemy.rect.x = n[0]
         enemy.rect.y = n[1]
         self.enemy_list.add(enemy)
     #X and Y for the score chests
     chest_list = []
     chest_level = [[300, 100], [550, 300]]
     for n in chest_level:
         chest = Chest()
         chest.rect.x = n[0]
         chest.rect.y = n[1]
         self.chest_list.add(chest)
예제 #4
0
	def gen_platform(self, plat):
		# Left side of platform
		plat_l = Platform(plat[0], plat[1])
		plat_l.rect.x = 0
		plat_l.rect.y = plat[2]
		plat_l.player = self.player
		
		# Right side of platform
		plat_r = Platform(SCREEN_WIDTH - plat[0] - GAP_LEN, plat[1])
		plat_r.rect.x = plat[0] + GAP_LEN
		plat_r.rect.y = plat[2]
		plat_r.player = self.player
		
		# Add both platforms to platform_list
		self.platform_list.add(plat_l)
		self.platform_list.add(plat_r)
예제 #5
0
    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, 30, 450, 570],
            [210, 30, 850, 420],
            [210, 30, 1000, 520],
            [210, 30, 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)
예제 #6
0
    def __init__(self, player):
        """ Create level 2. """

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

        # Pozycja startowa gracza
        self.start = [300, 400]

        # Choinka
        self.tree_pos = (50, 165)

        # Array with width, height, x, and y of platform

        level = [
            *Platforma(40, 450, 3), *Platforma(260, 360, 3),
            *Platforma(40, 270, 3), *Platforma(260, 180, 3),
            *Platforma(530, 450, 3), *Platforma(420, 340, 2),
            *Platforma(680, 340, 2), *Platforma(550, 250, 2),
            *Platforma(640, 150, 3)
        ]

        # Go through the array above and add platforms
        for platform in level:
            block = Platform(platform[0], platform[1], platform[4])
            block.rect.x = platform[2]
            block.rect.y = platform[3]
            block.player = self.player
            self.platform_list.add(block)

        walls = []
        door = []
        seg_pion = int(SCREEN_HEIGHT / 40)
        seg_poz = int(SCREEN_WIDTH / 40)
        for i in range(seg_poz):
            walls.append([40, 40, 40 * i, 0])  # sufit
            walls.append([40, 40, 40 * i, SCREEN_HEIGHT - 40])  # podłoga
        for i in range(seg_pion):
            walls.append([40, 40, 0, 40 * i])  # lewa ściana
        for i in range(9):
            walls.append([40, 40, SCREEN_WIDTH - 40, 40 * i])  # prawa ściana
        for i in range(9, 12):
            door.append([40, 40, SCREEN_WIDTH - 40, 40 * i])
        for i in range(12, seg_pion):
            walls.append([40, 40, SCREEN_WIDTH - 40, 40 * i])
        for i in range(10):
            walls.append([40, 40, 380, 520 - 40 * i])

        for platform in walls:
            wall = Platform(platform[0], platform[1], 1)
            wall.rect.x = platform[2]
            wall.rect.y = platform[3]
            wall.player = self.player
            self.wall_list.add(wall)

        for platform in door:
            wall = Platform(platform[0], platform[1], 1)
            wall.rect.x = platform[2]
            wall.rect.y = platform[3]
            wall.player = self.player
            self.door_list.add(wall)

        # Wrogowie z poziomu
        self.enemy_list.add(Enemy(50, 150, 1, "R"))
        self.enemy_list.add(Enemy(700, 50, 2, "L"))
        self.enemy_list.add(Enemy(430, 450, 3, "R"))

        # Prezenty
        self.gift_list.add(Gift(385, 130, "Blue"))
        self.gift_list.add(Gift(570, 220, "Red"))
        #self.gift_list.add(Gift(45,530,"Green"))

        # Dźwignia
        self.lever_list.add(Candy(70, 409))
        self.candy_pushed = [70, 419]
예제 #7
0
    def __init__(self, player):
        """ Create level 2. """

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

        # Pozycja startowa gracza
        self.start = [680, 350]

        # Choinka
        self.tree_pos = (695, 95)

        # Array with width, height, x, and y of platform

        level = [
            *Platforma(560, 200, 5),
            Platforma(640, 180, 1), *Platforma(360, 300, 4),
            *Platforma(40, 200, 4),
            Platforma(360, 100, 1)
        ]
        #print(level)

        # Go through the array above and add platforms
        for platform in level:
            block = Platform(platform[0], platform[1], platform[4])
            block.rect.x = platform[2]
            block.rect.y = platform[3]
            block.player = self.player
            self.platform_list.add(block)

        walls = []
        door = []
        seg_pion = int(SCREEN_HEIGHT / 40)
        seg_poz = int(SCREEN_WIDTH / 40)
        for i in range(2):
            walls.append([40, 40, 40 * i, 0])  # sufit
            walls.append([40, 40, 40 * i, SCREEN_HEIGHT - 40])
        for i in range(5, seg_poz):
            walls.append([40, 40, 40 * i, 0])  # sufit
            walls.append([40, 40, 40 * i, SCREEN_HEIGHT - 40])  # podłoga
        for i in range(seg_pion):
            walls.append([40, 40, 0, 40 * i])  # lewa ściana
        for i in range(8):
            walls.append([40, 40, SCREEN_WIDTH - 40, 40 * i])  # prawa ściana
        for i in range(8, 11):
            door.append([40, 40, SCREEN_WIDTH - 40, 40 * i])
        for i in range(11, seg_pion):
            walls.append([40, 40, SCREEN_WIDTH - 40, 40 * i])
        walls.append([40, 40, 520, 40])
        walls.append([40, 40, 520, 180])
        walls.append([40, 40, 200, 520])
        walls.append([40, 40, 200, 480])

        for platform in walls:
            wall = Platform(platform[0], platform[1], 1)
            wall.rect.x = platform[2]
            wall.rect.y = platform[3]
            wall.player = self.player
            self.wall_list.add(wall)

        for platform in door:
            wall = Platform(platform[0], platform[1], 1)
            wall.rect.x = platform[2]
            wall.rect.y = platform[3]
            wall.player = self.player
            self.door_list.add(wall)

        # Wrogowie z poziomu
        self.enemy_list.add(Enemy(80, 100, 1, "R"))
        self.enemy_list.add(Enemy(600, 300, 2, "L"))
        self.enemy_list.add(Enemy(680, 100, 3, "L"))

        # Prezenty
        self.gift_list.add(Gift(365, 70, "Blue"))
        #self.gift_list.add(Gift(645,220,"Red"))
        self.gift_list.add(Gift(45, 530, "Green"))

        # Dźwignia
        self.lever_list.add(Candy(647, 140))
        self.candy_pushed = [647, 150]
예제 #8
0
    def __init__(self,player):
 
        Level.__init__(self, player)
        self.obstacles = [
                     [800,20,20,SCREEN_HEIGHT-120],
                     [200,20,860,SCREEN_HEIGHT-120],
                     [SCREEN_WIDTH-380,20,400,SCREEN_HEIGHT-220],
                     [150,20,210,SCREEN_HEIGHT-220],
                     [700,20,20,SCREEN_HEIGHT-320],
                     [300,20,760,SCREEN_HEIGHT-320],
                     [SCREEN_WIDTH-380,20,400,SCREEN_HEIGHT-420],
                     [200,20,160,SCREEN_HEIGHT-420],
                     [500,20,20,SCREEN_HEIGHT-520],
                     [400,20,560,SCREEN_HEIGHT-520],
                     [SCREEN_WIDTH-330,20,350,SCREEN_HEIGHT-620],
                     [100,20,210,SCREEN_HEIGHT-620],
                     [750,20,20,SCREEN_HEIGHT-720],
                     [200,20,810,SCREEN_HEIGHT-720],
                     [SCREEN_WIDTH-380,20,400,SCREEN_HEIGHT-820],
                     [150,20,210,SCREEN_HEIGHT-820],
                     [100,20,600,SCREEN_HEIGHT-920],
                     [200,20,740,SCREEN_HEIGHT-920],
                 ]
        self.ladders  = [
                [820,SCREEN_HEIGHT-120,55,100],
                [350,SCREEN_HEIGHT-220,55,100],
                [710,SCREEN_HEIGHT-320,55,100],
                [350,SCREEN_HEIGHT-420,55,100],
                [515,SCREEN_HEIGHT-520,55,100],
                [305,SCREEN_HEIGHT-620,55,100],
                [755,SCREEN_HEIGHT-720,55,100],
                [355,SCREEN_HEIGHT-820,55,100],
                [695,SCREEN_HEIGHT-920,55,100],
                [800,SCREEN_HEIGHT-220,55,30],
                [800,SCREEN_HEIGHT-160,55,20],
                [800,SCREEN_HEIGHT-620,55,30],
                [800,SCREEN_HEIGHT-560,55,20]
                
                
            ]
        L = [self.level[0],self.level[2]]
        for platform in L:
            k = platform[3]
            for i in range(platform[1]/16):
                block = Platform()
                block.rect.x = platform[2]
                block.rect.y = k
                self.platform_list.add(block)
                k+=16
        
        __level = [self.level[1],self.level[3]]
        for i in self.obstacles:
            __level.append(i)
 
        for platform in __level:
            __k = platform[2]
            for i in range(platform[0]/16):
                block = Platform()
                block.rect.x = __k
                block.rect.y = platform[3]
                block.player = self.player
                self.platform_list.add(block)
                __k+=16

        for ladder in self.ladders:
            block = Ladders(ladder[2],ladder[3])
            block.rect.x = ladder[0]
            block.rect.y = ladder[1]
            self.ladder_list.add(block)