示例#1
0
    def __init__(self, file, load_image):
        read_list = open(file, encoding='utf-8').readlines()
        self.w_n = len(read_list[0]) - 1
        self.h_n = len(read_list)
        self.board = [list(i.strip()) for i in read_list]

        # json
        read_list = open('list_levels_j.json', 'r',
                         encoding='utf-8').readline()
        read_list = json.loads(read_list)
        self.level_list = [
            Level(int(i[0]),
                  int(i[1]),
                  i[2],
                  i[3],
                  i[4],
                  level_sprites,
                  ready=i[5]) for i in read_list
        ]

        self.shop = Shop(shop_sprite)

        self.left = 0
        self.top = 0

        self.pers = ''
        self.cell_size = WIDTH // 60
        self.bereg = pygame.transform.scale(
            load_image('bereg.jpg', 'data_menu'),
            (self.cell_size, self.cell_size))
        self.bereg_gor = pygame.transform.scale(
            load_image('bereg_gor.jpg', 'data_menu'),
            (self.cell_size, self.cell_size))
        self.more_spok = pygame.transform.scale(
            load_image('more_spok.jpg', 'data_menu'),
            (self.cell_size, self.cell_size))
        self.pesok = pygame.transform.scale(
            load_image('pesok.jpg', 'data_menu'),
            (self.cell_size, self.cell_size))
        self.zemlya = pygame.transform.scale(
            load_image('zemlya.jpg', 'data_menu'),
            (self.cell_size, self.cell_size))

        self.bereg_gor2 = pygame.transform.flip(self.bereg_gor, True, False)
        self.bereg2 = pygame.transform.flip(self.bereg, False, True)
示例#2
0
 def __init__(self, x0, y0, w, h, horizontal, rev, *group):
     super().__init__(*group)
     self.napr = ''
     if horizontal:
         if rev:
             self.image = pygame.transform.scale(
                 load_image('туманность.jpg', 'data_menu'),
                 (w * 2, HEIGHT // 2))
             self.rect = pygame.rect.Rect(x0 - w // 2,
                                          y0 - self.image.get_height(),
                                          *self.image.get_size())
             self.napr = 'up'
         else:
             self.image = pygame.transform.scale(
                 pygame.transform.flip(
                     load_image('туманность.jpg', 'data_menu'), False,
                     True), (w * 2, HEIGHT // 2))
             self.rect = pygame.rect.Rect(x0 - w // 2, y0 + h,
                                          *self.image.get_size())
             self.napr = 'down'
     else:
         if rev:
             self.image = pygame.transform.scale(
                 load_image('туманность_rev.jpg', 'data_menu'),
                 (WIDTH // 2, h))
             self.rect = pygame.rect.Rect(x0 - self.image.get_width(), y0,
                                          *self.image.get_size())
             self.napr = 'left'
         else:
             self.image = pygame.transform.scale(
                 pygame.transform.flip(
                     load_image('туманность_rev.jpg', 'data_menu'), False,
                     True), (WIDTH // 2, h))
             self.rect = pygame.rect.Rect(x0 + w, y0,
                                          *self.image.get_size())
             self.napr = 'right'
示例#3
0
 def re_list(self, cell_size):
     self.im_pictures = [
         pygame.transform.scale(
             load_image(f'boat_up{skin_number}.png', 'data_menu'),
             (cell_size, cell_size)),
         pygame.transform.scale(
             load_image(f'boat_up{skin_number + 1}.png', 'data_menu'),
             (cell_size, cell_size)),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'boat_up{skin_number}.png', 'data_menu'),
                 (cell_size, cell_size)), False, True),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'boat_up{skin_number + 1}.png', 'data_menu'),
                 (cell_size, cell_size)), False, True),
         pygame.transform.scale(
             load_image(f'boat_ri{skin_number}.png', 'data_menu'),
             (cell_size, cell_size)),
         pygame.transform.scale(
             load_image(f'boat_ri{skin_number + 1}.png', 'data_menu'),
             (cell_size, cell_size)),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'boat_ri{skin_number}.png', 'data_menu'),
                 (cell_size, cell_size)), True, False),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'boat_ri{skin_number + 1}.png', 'data_menu'),
                 (cell_size, cell_size)), True, False),
         pygame.transform.scale(
             load_image(f'horse_ri{skin_number}.png', 'data_menu'),
             (cell_size, cell_size)),
         pygame.transform.scale(
             load_image(f'horse_up{skin_number}.png', 'data_menu'),
             (cell_size, cell_size)),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'horse_up{skin_number}.png', 'data_menu'),
                 (cell_size, cell_size)), False, True),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'horse_ri{skin_number}.png', 'data_menu'),
                 (cell_size, cell_size)), True, False),
         pygame.transform.scale(
             load_image(f'boat_diri{skin_number}.png', 'data_menu'),
             (cell_size, cell_size)),
         pygame.transform.scale(
             load_image(f'boat_diri{skin_number + 1}.png', 'data_menu'),
             (cell_size, cell_size)),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'boat_diri{skin_number}.png', 'data_menu'),
                 (cell_size, cell_size)), False, True),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'boat_diri{skin_number + 1}.png', 'data_menu'),
                 (cell_size, cell_size)), False, True),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'boat_diri{skin_number}.png', 'data_menu'),
                 (cell_size, cell_size)), True, False),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'boat_diri{skin_number + 1}.png', 'data_menu'),
                 (cell_size, cell_size)), True, False),
         pygame.transform.flip(
             pygame.transform.flip(
                 pygame.transform.scale(
                     load_image(f'boat_diri{skin_number}.png', 'data_menu'),
                     (cell_size, cell_size)), False, True), True, False),
         pygame.transform.flip(
             pygame.transform.flip(
                 pygame.transform.scale(
                     load_image(f'boat_diri{skin_number + 1}.png',
                                'data_menu'), (cell_size, cell_size)),
                 False, True), True, False),
         pygame.transform.scale(
             load_image(f'horse_diri{skin_number}.png', 'data_menu'),
             (cell_size, cell_size)),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'horse_diri{skin_number}.png', 'data_menu'),
                 (cell_size, cell_size)), True, False),
         pygame.transform.flip(
             pygame.transform.scale(
                 load_image(f'horse_diri{skin_number}.png', 'data_menu'),
                 (cell_size, cell_size)), False, True),
         pygame.transform.flip(
             pygame.transform.flip(
                 pygame.transform.scale(
                     load_image(f'horse_diri{skin_number}.png',
                                'data_menu'), (cell_size, cell_size)),
                 False, True), True, False)
     ]
示例#4
0
    def __init__(self, x, y, cell_size, *group):
        super().__init__(*group)

        self.sound_water = pygame.mixer.Sound(
            os.path.join('sounds', 'бульк.wav'))
        self.sound_horse = pygame.mixer.Sound(
            os.path.join('sounds', 'horse.wav'))
        self.sound_horse.set_volume(0.15)

        self.change = 0
        self.im_pictures = [
            pygame.transform.scale(
                load_image(f'boat_up{skin_number}.png', 'data_menu'),
                (cell_size, cell_size)),
            pygame.transform.scale(
                load_image(f'boat_up{skin_number + 1}.png', 'data_menu'),
                (cell_size, cell_size)),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'boat_up{skin_number}.png', 'data_menu'),
                    (cell_size, cell_size)), False, True),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'boat_up{skin_number + 1}.png', 'data_menu'),
                    (cell_size, cell_size)), False, True),
            pygame.transform.scale(
                load_image(f'boat_ri{skin_number}.png', 'data_menu'),
                (cell_size, cell_size)),
            pygame.transform.scale(
                load_image(f'boat_ri{skin_number + 1}.png', 'data_menu'),
                (cell_size, cell_size)),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'boat_ri{skin_number}.png', 'data_menu'),
                    (cell_size, cell_size)), True, False),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'boat_ri{skin_number + 1}.png', 'data_menu'),
                    (cell_size, cell_size)), True, False),
            pygame.transform.scale(
                load_image(f'horse_ri{skin_number}.png', 'data_menu'),
                (cell_size, cell_size)),
            pygame.transform.scale(
                load_image(f'horse_up{skin_number}.png', 'data_menu'),
                (cell_size, cell_size)),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'horse_up{skin_number}.png', 'data_menu'),
                    (cell_size, cell_size)), False, True),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'horse_ri{skin_number}.png', 'data_menu'),
                    (cell_size, cell_size)), True, False),
            pygame.transform.scale(
                load_image(f'boat_diri{skin_number}.png', 'data_menu'),
                (cell_size, cell_size)),
            pygame.transform.scale(
                load_image(f'boat_diri{skin_number + 1}.png', 'data_menu'),
                (cell_size, cell_size)),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'boat_diri{skin_number}.png', 'data_menu'),
                    (cell_size, cell_size)), False, True),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'boat_diri{skin_number + 1}.png', 'data_menu'),
                    (cell_size, cell_size)), False, True),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'boat_diri{skin_number}.png', 'data_menu'),
                    (cell_size, cell_size)), True, False),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'boat_diri{skin_number + 1}.png', 'data_menu'),
                    (cell_size, cell_size)), True, False),
            pygame.transform.flip(
                pygame.transform.flip(
                    pygame.transform.scale(
                        load_image(f'boat_diri{skin_number}.png', 'data_menu'),
                        (cell_size, cell_size)), False, True), True, False),
            pygame.transform.flip(
                pygame.transform.flip(
                    pygame.transform.scale(
                        load_image(f'boat_diri{skin_number + 1}.png',
                                   'data_menu'), (cell_size, cell_size)),
                    False, True), True, False),
            pygame.transform.scale(
                load_image(f'horse_diri{skin_number}.png', 'data_menu'),
                (cell_size, cell_size)),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'horse_diri{skin_number}.png', 'data_menu'),
                    (cell_size, cell_size)), True, False),
            pygame.transform.flip(
                pygame.transform.scale(
                    load_image(f'horse_diri{skin_number}.png', 'data_menu'),
                    (cell_size, cell_size)), False, True),
            pygame.transform.flip(
                pygame.transform.flip(
                    pygame.transform.scale(
                        load_image(f'horse_diri{skin_number}.png',
                                   'data_menu'), (cell_size, cell_size)),
                    False, True), True, False)
        ]
        self.image = self.im_pictures[0]
        self.rect = pygame.rect.Rect(x, y, cell_size, cell_size)

        self.ves_lo = False
        self.left_run = False
        self.right_run = False
        self.up_run = False
        self.down_run = False
        self.in_ground = False
        self.arr_collide = [-1, -1]

        self.v = WIDTH // 11
示例#5
0
    def __init__(self, *group):
        super().__init__(*group)
        self.image = pygame.transform.scale(
            load_image('shop_and_home.jpg', 'data_menu'),
            (WIDTH // 20, WIDTH // 20))
        self.rect = pygame.rect.Rect(0, 0, *self.image.get_size())

        self.ri_arrow = pygame.transform.scale(
            load_image('стрелка в право.png', 'data_menu'),
            (WIDTH // 10, WIDTH // 20))
        self.le_arrow = pygame.transform.flip(
            pygame.transform.scale(
                load_image('стрелка в право.png', 'data_menu'),
                (WIDTH // 10, WIDTH // 20)), True, False)
        image_coin = load_image('coin.png', 'data')

        self.sound = pygame.mixer.Sound(
            os.path.join('sounds', 'распродажа.wav'))
        self.sound.set_volume(0.5)

        self.font2 = pygame.font.Font(None, 50)
        self.font1 = pygame.font.Font(None, 150)

        self.now_skin = skin_number
        self.screen2 = pygame.Surface([WIDTH // 2, HEIGHT // 2])
        self.screen2.fill('black')

        self.dict_of_num_skins = {
            1: {
                'open':
                True,
                'price':
                -1,
                'name':
                'классика',
                'img': [
                    pygame.transform.scale(
                        load_image(f'boat_diri1.png', 'data_menu'),
                        (self.screen2.get_width() // 6,
                         self.screen2.get_width() // 6)),
                    pygame.transform.scale(
                        load_image(f'horse_diri1.png', 'data_menu'),
                        (self.screen2.get_width() // 6,
                         self.screen2.get_width() // 6))
                ]
            },
            3: {
                'open':
                False,
                'price':
                50,
                'name':
                'цветок',
                'img': [
                    pygame.transform.scale(
                        load_image(f'boat_diri3.png', 'data_menu'),
                        (self.screen2.get_width() // 6,
                         self.screen2.get_width() // 6)),
                    pygame.transform.scale(
                        load_image(f'horse_diri3.png', 'data_menu'),
                        (self.screen2.get_width() // 6,
                         self.screen2.get_width() // 6))
                ]
            }
        }

        self.screen2.blit(self.le_arrow, (0, self.screen2.get_height() // 2 -
                                          self.le_arrow.get_height() // 2))
        self.screen2.blit(
            self.ri_arrow,
            (self.screen2.get_width() - self.le_arrow.get_width(),
             self.screen2.get_height() // 2 - self.le_arrow.get_height() // 2))
        self.screen2.blit(image_coin, (self.screen2.get_width() // 3, 0))