Exemplo n.º 1
0
 def build_0(self):
     """level 0"""
     pig1 = Pig(980, 100, self.space)  #create pigs
     pig2 = Pig(985, 182, self.space)
     self.pigs.append(pig1)
     self.pigs.append(pig2)
     #create Polygons
     p = (950, 80)  #position
     self.columns.append(Polygon(p, 20, 85, self.space))  #
     p = (1010, 80)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (980, 150)
     self.beams.append(Polygon(p, 85, 20, self.space))
     p = (950, 200)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (1010, 200)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (980, 240)
     self.beams.append(Polygon(p, 85, 20, self.space))
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
     self.one_star = 30000
     self.two_star = 40000
     self.three_star = 60000
Exemplo n.º 2
0
 def build_4(self):
     """level 4"""
     pig = Pig(900, 300, self.space)
     self.pigs.append(pig)
     pig = Pig(1000, 500, self.space)
     self.pigs.append(pig)
     pig = Pig(1100, 400, self.space)
     self.pigs.append(pig)
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
Exemplo n.º 3
0
 def build_3(self):
     """level 3"""
     pig = Pig(950, 320, self.space)
     pig.life = 25
     self.pigs.append(pig)
     pig = Pig(885, 225, self.space)
     pig.life = 25
     self.pigs.append(pig)
     pig = Pig(1005, 225, self.space)
     pig.life = 25
     self.pigs.append(pig)
     p = (1100, 100)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (1070, 152)
     self.beams.append(Polygon(p, 85, 20, self.space))
     p = (1040, 100)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (980, 100)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (920, 100)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (950, 152)
     self.beams.append(Polygon(p, 85, 20, self.space))
     p = (1010, 180)
     self.beams.append(Polygon(p, 85, 20, self.space))
     p = (860, 100)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (800, 100)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (830, 152)
     self.beams.append(Polygon(p, 85, 20, self.space))
     p = (890, 180)
     self.beams.append(Polygon(p, 85, 20, self.space))
     p = (860, 223)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (920, 223)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (980, 223)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (1040, 223)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (890, 280)
     self.beams.append(Polygon(p, 85, 20, self.space))
     p = (1010, 280)
     self.beams.append(Polygon(p, 85, 20, self.space))
     p = (950, 300)
     self.beams.append(Polygon(p, 85, 20, self.space))
     p = (920, 350)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (980, 350)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (950, 400)
     self.beams.append(Polygon(p, 85, 20, self.space))
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
Exemplo n.º 4
0
 def build_9(self):
     """level 9"""
     pig = Pig(1000, 180, self.space)
     pig.life = 20
     self.pigs.append(pig)
     pig = Pig(900, 180, self.space)
     pig.life = 20
     self.pigs.append(pig)
     self.open_flat(1050, 0, 3)
     self.open_flat(963, 0, 2)
     self.open_flat(880, 0, 2)
     self.open_flat(790, 0, 3)
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
Exemplo n.º 5
0
 def build_2(self):
     """level 2"""
     pig1 = Pig(880, 180, self.space)
     self.pigs.append(pig1)
     pig2 = Pig(1000, 230, self.space)
     self.pigs.append(pig2)
     p = (880, 80)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (880, 150)
     self.beams.append(Polygon(p, 85, 20, self.space))
     p = (1000, 80)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (1000, 180)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (1000, 210)
     self.beams.append(Polygon(p, 85, 20, self.space))
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
Exemplo n.º 6
0
 def build_8(self):
     """level 8"""
     pig = Pig(1000, 180, self.space)
     pig.life = 30
     self.pigs.append(pig)
     pig = Pig(1078, 280, self.space)
     pig.life = 30
     self.pigs.append(pig)
     pig = Pig(900, 80, self.space)
     pig.life = 30
     self.pigs.append(pig)
     self.open_flat(1050, 0, 3)
     self.open_flat(963, 0, 2)
     self.open_flat(880, 0, 1)
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
Exemplo n.º 7
0
 def build_7(self):
     """level 7"""
     pig = Pig(978, 180, self.space)
     pig.life = 30
     self.pigs.append(pig)
     pig = Pig(978, 280, self.space)
     pig.life = 30
     self.pigs.append(pig)
     pig = Pig(978, 80, self.space)
     pig.life = 30
     self.pigs.append(pig)
     self.open_flat(950, 0, 3)
     self.vertical_pile(850, 0, 3)
     self.vertical_pile(830, 0, 3)
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
Exemplo n.º 8
0
 def build_5(self):
     """level 5"""
     pig = Pig(900, 70, self.space)
     self.pigs.append(pig)
     pig = Pig(1000, 152, self.space)
     self.pigs.append(pig)
     for i in range(9):
         p = (800, 70+i*21)
         self.beams.append(Polygon(p, 85, 20, self.space))
     for i in range(4):
         p = (1000, 70+i*21)
         self.beams.append(Polygon(p, 85, 20, self.space))
     p = (970, 176)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (1026, 176)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (1000, 230)
     self.beams.append(Polygon(p, 85, 20, self.space))
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
Exemplo n.º 9
0
 def build_0(self):
     """level 0"""
     pig1 = Pig(980, 100, self.space)
     pig2 = Pig(985, 182, self.space)
     self.pigs.append(pig1)
     self.pigs.append(pig2)
     p = (950, 80)
     self.beams.append(Polygon(p, self.space, 3.14 / 2))
     p = (1010, 80)
     self.beams.append(Polygon(p, self.space, 3.14 / 2))
     p = (980, 150)
     self.beams.append(Polygon(p, self.space))
     p = (950, 200)
     self.beams.append(Polygon(p, self.space, 3.14 / 2))
     p = (1010, 200)
     self.beams.append(Polygon(p, self.space, 3.14 / 2))
     p = (980, 240)
     self.beams.append(Polygon(p, self.space))
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
     self.one_star = 30000
     self.two_star = 40000
     self.three_star = 60000
Exemplo n.º 10
0
 def build_1(self):
     """level 1"""
     pig = Pig(1000, 100, self.space)
     self.pigs.append(pig)
     p = (900, 80)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (850, 80)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (850, 150)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (1050, 150)
     self.columns.append(Polygon(p, 20, 85, self.space))
     p = (1105, 210)
     self.beams.append(Polygon(p, 85, 20, self.space))
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
Exemplo n.º 11
0
 def build_11(self):
     """level 11"""
     pig = Pig(820, 177, self.space)
     self.pigs.append(pig)
     pig = Pig(960, 150, self.space)
     self.pigs.append(pig)
     pig = Pig(1100, 130, self.space)
     self.pigs.append(pig)
     pig = Pig(890, 270, self.space)
     pig.life = 30
     self.pigs.append(pig)
     self.horizontal_pile(800, 0, 5)
     self.horizontal_pile(950, 0, 3)
     self.horizontal_pile(1100, 0, 2)
     self.vertical_pile(745, 0, 2)
     self.vertical_pile(855, 0, 2)
     self.vertical_pile(900, 0, 2)
     self.vertical_pile(1000, 0, 2)
     p = (875, 230)
     self.beams.append(Polygon(p, 85, 20, self.space))
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
Exemplo n.º 12
0
 def build_6(self):
     """level 6"""
     pig = Pig(920, 533, self.space)
     pig.life = 40
     self.pigs.append(pig)
     pig = Pig(820, 533, self.space)
     self.pigs.append(pig)
     pig = Pig(720, 633, self.space)
     self.pigs.append(pig)
     self.closed_flat(895, 423, 1)
     self.vertical_pile(900, 0, 5)
     self.vertical_pile(926, 0, 5)
     self.vertical_pile(950, 0, 5)
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
Exemplo n.º 13
0
 def build_10(self):
     """level 10"""
     pig = Pig(960, 250, self.space)
     pig.life = 20
     self.pigs.append(pig)
     pig = Pig(820, 160, self.space)
     self.pigs.append(pig)
     pig = Pig(1100, 160, self.space)
     self.pigs.append(pig)
     self.vertical_pile(900, 0, 3)
     self.vertical_pile(930, 0, 3)
     self.vertical_pile(1000, 0, 3)
     self.vertical_pile(1030, 0, 3)
     self.horizontal_pile(970, 250, 2)
     self.horizontal_pile(820, 0, 4)
     self.horizontal_pile(1100, 0, 4)
     self.number_of_birds = 4
     if self.bool_space:
         self.number_of_birds = 8
Exemplo n.º 14
0
        self.pages = piggy_pages

    def open(self):
        print self.title

    def turn_page(self):
        self.curr_page += 1
        if self.curr_page < len(self.pages):
            print self.pages[self.curr_page]

    def close(self):
        pass


# Setup
pigs = [Pig(), Pig(), Pig()]
piggy1 = pigs[0]
piggy2 = pigs[1]
piggy3 = pigs[2]
man = Man()
piggy1.build_house(Material.STRAW)
piggy2.build_house(Material.STICK)
piggy3.build_house(Material.BRICK)
wolf = Wolf()
wolf.description = "Big Bad"

piggy_pages = [
    """
Once upon a time, when pigs still could rhyme
There was a pig.
""" + str(Pig()), """
Exemplo n.º 15
0
                        elif event.key == pygame.K_d:
                            # Rotate clockwise
                            holding_body.body.angle -= math.pi / 4
                            # Snap angle
                            holding_body.body.angle = holding_body.body.angle // (
                                math.pi / 4) * (math.pi / 4)
                    elif event.key == pygame.K_n:
                        # New level
                        restart()
                    elif event.key == pygame.K_m:
                        columns.append(
                            Polygon(to_pymunk(pygame.mouse.get_pos()), 20, 85,
                                    space))

                    elif event.key == pygame.K_b:
                        pig = Pig(*to_pymunk(pygame.mouse.get_pos()), space)
                        pigs.append(pig)
                    elif event.key == pygame.K_s:
                        saving_level = True
                    elif event.key == pygame.K_l:
                        loading_level = True
            elif (saving_level
                  or loading_level) and event.type == pygame.KEYUP:
                # Add character to saving buffer
                # make sure the user hasn't typed anything evil
                assert pygame.key.name(event.key) not in ['/', '.']
                if event.key == pygame.K_RETURN:
                    if saving_level:
                        saving_level = False
                        with open('../levels/%s.pickle' % curr_text,
                                  'wb') as f:
Exemplo n.º 16
0
    def load_level(self):
        if self.number == 0:
            self.pigs.append(Pig(980, 100, self.space))
            self.pigs.append(Pig(985, 182, self.space))

            for p in [(950, 80), (1010, 80), (950, 200), (1010, 200)]:
                # b = Rectangle(p, 'images/beam.png', self.space)

                self.columns.append(Polygon(p, 20, 85, self.space))

            for p in [(980, 240), (980, 150)]:
                self.beams.append(Polygon(p, 85, 20, self.space))

            self.number_of_birds = 8 if self.bool_space else 4

        elif self.number == 1:
            self.pigs.append(Pig(1000, 100, self.space))
            for p in [(900, 80), (850, 80), (850, 150), (1050, 150)]:
                self.columns.append(Polygon(p, 20, 85, self.space))

            p = (1105, 210)
            self.beams.append(Polygon(p, 85, 20, self.space))

        elif self.number == 2:
            self.pigs.append(Pig(880, 180, self.space))
            self.pigs.append(Pig(1000, 230, self.space))

            for p in [(880, 80), (1000, 80), (1000, 180)]:
                self.columns.append(Polygon(p, 20, 85, self.space))

            p = (1000, 210)
            self.beams.append(Polygon(p, 85, 20, self.space))
            p = (880, 150)
            self.beams.append(Polygon(p, 85, 20, self.space))

        elif self.number == 3:
            self.pigs.append(Pig(950, 320, self.space, 25))
            self.pigs.append(Pig(885, 225, self.space, 25))
            self.pigs.append(Pig(1005, 225, self.space, 25))

            for p in [(1100, 100), (1040, 100), (980, 100), (920, 100),
                      (860, 100), (800, 100), (860, 223), (920, 223),
                      (980, 223), (1040, 223), (920, 350), (980, 350)]:
                self.columns.append(Polygon(p, 20, 85, self.space))

            for p in [(890, 280), (1010, 280), (950, 300), (950, 400),
                      (1070, 152), (950, 152), (1010, 180), (830, 152),
                      (890, 180)]:
                self.beams.append(Polygon(p, 85, 20, self.space))

        elif self.number == 4:
            self.pigs.append(Pig(900, 300, self.space))
            self.pigs.append(Pig(1000, 500, self.space))
            self.pigs.append(Pig(1100, 400, self.space))

        elif self.number == 5:
            self.pigs.append(Pig(900, 70, self.space))
            self.pigs.append(Pig(1000, 152, self.space))

            for i in range(9):
                p = (800, 70 + i * 21)
                self.beams.append(Polygon(p, 85, 20, self.space))
            for i in range(4):
                p = (1000, 70 + i * 21)
                self.beams.append(Polygon(p, 85, 20, self.space))
            p = (970, 176)
            self.columns.append(Polygon(p, 20, 85, self.space))
            p = (1026, 176)
            self.columns.append(Polygon(p, 20, 85, self.space))
            p = (1000, 230)
            self.beams.append(Polygon(p, 85, 20, self.space))

        elif self.number == 6:
            self.pigs.append(Pig(920, 533, self.space, 40))
            self.pigs.append(Pig(820, 533, self.space))
            self.pigs.append(Pig(720, 633, self.space))

            self.closed_flat(895, 423, 1)
            self.vertical_pile(900, 0, 5)
            self.vertical_pile(926, 0, 5)
            self.vertical_pile(950, 0, 5)

        elif self.number == 7:
            self.pigs.append(Pig(978, 180, self.space, 30))
            self.pigs.append(Pig(978, 280, self.space, 30))
            self.pigs.append(Pig(978, 80, self.space, 30))

            self.open_flat(950, 0, 3)
            self.vertical_pile(850, 0, 3)
            self.vertical_pile(830, 0, 3)

        elif self.number == 8:
            self.pigs.append(Pig(1000, 180, self.space, 30))
            self.pigs.append(Pig(1078, 280, self.space, 30))
            self.pigs.append(Pig(900, 80, self.space, 30))

            self.open_flat(1050, 0, 3)
            self.open_flat(963, 0, 2)
            self.open_flat(880, 0, 1)

        elif self.number == 9:
            self.pigs.append(Pig(1000, 180, self.space))
            self.pigs.append(Pig(900, 180, self.space))

            self.open_flat(1050, 0, 3)
            self.open_flat(963, 0, 2)
            self.open_flat(880, 0, 2)
            self.open_flat(790, 0, 3)

        elif self.number == 10:
            self.pigs.append(Pig(960, 250, self.space))
            self.pigs.append(Pig(820, 160, self.space))
            self.pigs.append(Pig(1100, 160, self.space))

            self.vertical_pile(900, 0, 3)
            self.vertical_pile(930, 0, 3)
            self.vertical_pile(1000, 0, 3)
            self.vertical_pile(1030, 0, 3)
            self.horizontal_pile(970, 250, 2)
            self.horizontal_pile(820, 0, 4)
            self.horizontal_pile(1100, 0, 4)

        elif self.number == 11:
            self.pigs.append(Pig(820, 177, self.space))
            self.pigs.append(Pig(960, 150, self.space))
            self.pigs.append(Pig(1100, 130, self.space))
            self.pigs.append(Pig(890, 270, self.space, 30))

            self.horizontal_pile(800, 0, 5)
            self.horizontal_pile(950, 0, 3)
            self.horizontal_pile(1100, 0, 2)
            self.vertical_pile(745, 0, 2)
            self.vertical_pile(855, 0, 2)
            self.vertical_pile(900, 0, 2)
            self.vertical_pile(1000, 0, 2)
            p = (875, 230)
            self.beams.append(Polygon(p, 85, 20, self.space))

        self.number_of_birds = 4 if not self.bool_space else 8