Ejemplo n.º 1
0
    def loop(self):
        game_level = 1
        wall_list = build_room.choice_wall()

        while 1:



            if game_level <= self.len:
                pygame.mixer.music.load(data.filepath('Audio', 'theme.mp3'))
                pygame.mixer.music.set_volume(const.SOUND_VOLUME)
                pygame.mixer.music.play(-1)

                level_str = "level_" + str(game_level)
                level_info = self.level_info[level_str]
                wall_img = random.choice(wall_list)

                Level(self, level_info, game_level, wall_img).loop()

                game_level += 1

            elif game_level <= 0:
                pygame.mixer.music.load(data.filepath('Audio', 'lose.wav'))
                pygame.mixer.music.set_volume(const.SOUND_VOLUME / 2)
                pygame.mixer.music.play(-1)
                self.lose_game()

            elif game_level > self.len:
                pygame.mixer.music.load(data.filepath('Audio', 'win.wav'))
                pygame.mixer.music.set_volume(const.SOUND_VOLUME / 2)
                pygame.mixer.music.play(-1)
                self.win_game()
Ejemplo n.º 2
0
    def animate(self, start_string, directory, image_count):
        restartbar = pygame.transform.scale(pygame.image.load(data.filepath("Cover",
                                                      "restart-01.png")), (118, 59))
        image_num = 0
        num_str = '{0:03}'.format(image_num)
        button = None
        image = pygame.image.load(data.filepath(directory,
                                            start_string + num_str + ".png"))

        pygame.transform.scale(self.screen, (2 * const.WIDTH, 2 * const.HEIGHT),
                               self.real_screen)
        pygame.display.update()

        last_time = pygame.time.get_ticks()
        restart = False
        while not restart:

            self.screen.blit(image, (0, 0))

            if image_num == image_count:
                button = self.screen.blit(restartbar, (500, 600))
            elif pygame.time.get_ticks() > last_time + 20:
                image_num += 1
                num_str = '{0:03}'.format(image_num)
                image = pygame.image.load(data.filepath(directory,
                                                start_string + num_str + ".png"))
                last_time = pygame.time.get_ticks()

            pygame.transform.scale(self.screen, (2 * const.WIDTH, 2 * const.HEIGHT),
                                   self.real_screen)
            pygame.display.flip()

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.mixer.music.stop()
                    pygame.quit()
                    exit(0)

                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        pygame.mixer.music.fadeout(const.FADEOUT_TIME)
                        sys.exit()

                if image_num == image_count and button:
                    if event.type == pygame.MOUSEBUTTONDOWN:
                        if event.button == 1:
                            position = pygame.mouse.get_pos()
                            if button.collidepoint(position):
                                restart = True
Ejemplo n.º 3
0
    def loop(self, audio_file, fadeout):
        eye_img = pygame.transform.scale(pygame.image.load(data.filepath("Transitions",
                                                        'eye.png')), (300, 300))
        info_img = pygame.transform.scale(pygame.image.load(data.filepath("Transitions",
                                                        'info.png')), (550, 550))
        click = pygame.image.load(data.filepath("Transitions", "click.png"))


        self.screen.blit(eye_img, (200, 0))
        self.screen.blit(info_img, (100, 200))
        pygame.transform.scale(self.screen, (2 * const.WIDTH, 2 * const.HEIGHT),
                               self.real_screen)
        pygame.display.flip()

        pygame.mixer.music.fadeout(fadeout)
        pygame.mixer.music.load(data.filepath("Audio", audio_file))
        pygame.mixer.music.set_volume(const.SOUND_VOLUME / 8)
        pygame.mixer.music.play(-1)
        click_time = pygame.time.get_ticks()

        while not self.move_on:

            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN:

                    if event.key == pygame.K_ESCAPE:
                        sys.exit()

                    elif event.key == pygame.K_SPACE:
                        self.move_on = True

                elif event.type == pygame.QUIT:
                    sys.exit()

                elif event.type == pygame.MOUSEBUTTONDOWN:
                    self.move_on = True

            if self.move_on is True:
                pygame.mixer.music.stop()

            if pygame.time.get_ticks() >= click_time + const.FADEOUT_TIME:
                self.screen.blit(click, (340, 620))
            pygame.transform.scale(self.screen, (2 * const.WIDTH, 2 * const.HEIGHT),
                                   self.real_screen)
            pygame.display.flip()

        return self.move_on
Ejemplo n.º 4
0
 def __init__(self, window):
     self.window = window
     self.real_screen = window.real_screen
     self.screen = pygame.surface.Surface((2 * const.WIDTH, 2 * const.HEIGHT))
     self.clock = window.clock
     self.dt = window.dt
     self.level_info =  yaml.load(open(data.filepath('Level', 'level_info.yaml')))
     self.len = len(self.level_info.keys())
Ejemplo n.º 5
0
 def __init__(self, width, height, screen_width, screen_hight, name, img_name,
                                                                     screen):
     self.name = name
     self.image = pygame.transform.scale(pygame.image.load(data.filepath(
                           "Level", img_name)), (width, height))
     self.button = screen.blit(self.image, (screen_width, screen_hight))