Esempio n. 1
0
    def __init__(self, player_group, all_sprites, pos_x, pos_y, walls=[]):
        super().__init__(player_group, all_sprites)
        self.image = load_image('skin', 'player.png', -1)
        self.tile_size = 64

        self.walls = walls

        self.x, self.y = pos_x, pos_y
        self.rect = self.image.get_rect().move(self.tile_size * pos_x,
                                               self.tile_size * pos_y)
        self.step = 1
        self.cur_frame = 0
        self.frames = []

        self.direction = "down"  # Изначальное направление
        # нарезка кадров для всех направлений
        self.runRightImages = self.cut_sheet(
            load_image('skin', 'right.png', -1), 4, 1)
        self.runLeftImages = self.cut_sheet(load_image('skin', 'left.png', -1),
                                            4, 1)
        self.runUpImages = self.cut_sheet(load_image('skin', 'up.png', -1), 4,
                                          1)
        self.runDownImages = self.cut_sheet(load_image('skin', 'down.png', -1),
                                            4, 1)
        # для анимации
        self.pauseAnim = 0.3
        self.getTicksLastFrame = pygame.time.get_ticks()

        self.yvel = 0
        self.xvel = 0
Esempio n. 2
0
 def __init__(self,
              sprite_group,
              all_sprites,
              direct,
              pos_x,
              pos_y,
              active=True):
     super().__init__(sprite_group, all_sprites)
     self.direction = direct
     self.status = active
     self.image = load_image('bigpic', 'exit.png')
     if not self.status:
         self.image = load_image('bigpic', 'unable.png')
     self.x, self.y = pos_x, pos_y
     self.rect = self.image.get_rect().move(tile_size * pos_x,
                                            tile_size * pos_y)
Esempio n. 3
0
 def __init__(self, sprite_group, tag, all_sprites, pos_x, pos_y):
     super().__init__(sprite_group, all_sprites)
     self.mark = tag
     self.image = load_image('bigpic', 'chest.png')
     self.rect = self.image.get_rect().move(tile_size * pos_x,
                                            tile_size * pos_y)
     self.speak_wind = pygame.Surface([640, 64])
Esempio n. 4
0
 def __init__(self, sprite_group, all_sprites, pos_x, pos_y, angl):
     super().__init__(sprite_group, all_sprites)
     self.angle = angl
     img = 'tri-' + str(self.angle) + '.png'
     self.image = load_image('bigpic', img, -1)
     self.rect = self.image.get_rect().move(tile_size * pos_x,
                                            tile_size * pos_y)
Esempio n. 5
0
 def __init__(self, pers_group, all_sprites, name, talk, pos_x, pos_y):
     super().__init__(pers_group, all_sprites)
     pic_name = name + '.png'
     self.image = load_image('skin', pic_name, -1)
     self.emotions = []
     self.emotion = None
     self.name = name
     self.talked = talk
     self.d_color = pygame.Color(0, 0, 0)
     for i in range(2):
         pic_name = 'em-' + name + '-' + str(i) + '.png'
         self.emotions.append(load_image('skin', pic_name))
     self.dialog = []
     self.d_wid, self.d_hei = 640, 128
     self.d_x, self.d_y = 0, 512
     self.rect = self.image.get_rect().move(tile_size * pos_x,
                                            tile_size * pos_y)
Esempio n. 6
0
 def tellstory(self):
     screen = pygame.display.set_mode(self.size)
     while self.running:
         fon = pygame.transform.scale(load_image('prolog', self.naming),
                                      (self.width, self.height))
         screen.blit(fon, (0, 0))
         for event in pygame.event.get():
             if event.type == pygame.QUIT:
                 self.running = False
                 terminate()
             elif event.type == pygame.KEYDOWN or \
                     event.type == pygame.MOUSEBUTTONDOWN:
                 self.curr_cadr += 1  # смена кадра после нажатия
                 if self.curr_cadr > self.all_cadr:
                     self.running = False
                     return
                 else:
                     self.naming = 'P' + str(self.curr_cadr) + '.png'
                     fon = pygame.transform.scale(
                         load_image('prolog', self.naming),
                         (self.width, self.height))
                     screen.blit(fon, (0, 0))
         pygame.display.flip()
Esempio n. 7
0
 def showing(self):
     screen = pygame.display.set_mode(self.size)
     fon = pygame.transform.scale(load_image('bigpic', self.pic_name),
                                  (self.width, self.height))
     screen.blit(fon, (0, 0))
     pygame.display.flip()
     while self.watch:
         for event in pygame.event.get():
             if event.type == pygame.QUIT:
                 self.watch = False
                 return 'termination'
             elif event.type == pygame.KEYDOWN or \
                     event.type == pygame.MOUSEBUTTONDOWN:
                 self.watch = False
                 return 'termination'
Esempio n. 8
0
 def mainmenu(self):
     screen = pygame.display.set_mode(self.size)
     but_in_menu = []
     continue_but = Button('Продолжить', self.offset, self.titlspace)
     but_in_menu.append(continue_but)
     new_g_but = Button('Новая игра', self.offset,
                        self.titlspace + self.space)
     but_in_menu.append(new_g_but)
     ach_but = Button('Достижения', self.offset,
                      self.titlspace + self.space * 2)
     but_in_menu.append(ach_but)
     pre_but = Button('Предыстория', self.offset,
                      self.titlspace + self.space * 3)
     but_in_menu.append(pre_but)
     exit_but = Button('Выход', self.offset,
                       self.titlspace + self.space * 4)
     but_in_menu.append(exit_but)
     header = load_image('bigpic', 'title.png')
     while self.run:
         screen.fill(self.clr)
         screen.blit(header, (self.offset - 20, 11))
         for event in pygame.event.get():
             if event.type == pygame.QUIT:
                 self.run = False
                 terminate()
             if event.type == pygame.MOUSEMOTION:
                 for i in but_in_menu:
                     pos = pygame.mouse.get_pos()
                     i.set_hov(i.onclick(pos))
             elif event.type == pygame.MOUSEBUTTONDOWN:
                 pos = pygame.mouse.get_pos()
                 if continue_but.onclick(pos):  # Проверка нажатия
                     self.run = False
                     return 'continue'
                 if new_g_but.onclick(pos):
                     self.run = False
                     return 'new game'
                 if ach_but.onclick(pos):
                     self.run = False
                     return 'achievements'
                 if pre_but.onclick(pos):
                     Prologue().tellstory()
                 if exit_but.onclick(pos):
                     self.run = False
                     return 'termination'
         for i in but_in_menu:
             i.draw(screen)
         pygame.display.flip()
Esempio n. 9
0
 def turn(self):
     self.angle += 90
     if self.angle == 360:
         self.angle = 0
     img = 'tri-' + str(self.angle) + '.png'
     self.image = load_image('bigpic', img, -1)
Esempio n. 10
0
 def __init__(self, sprite_group, tag, all_sprites, pos_x, pos_y):
     super().__init__(sprite_group, all_sprites)
     self.image = load_image('bigpic', tag + '.png')
     self.tag = tag
     self.rect = self.image.get_rect().move(tile_size * pos_x,
                                            tile_size * pos_y)