Ejemplo n.º 1
0
def fourth_level():
    global count, level
    sound_start.play()
    pygame.mixer.music.play(-1)
    level = fourth_level
    TARELKA_EVENT = pygame.USEREVENT + 1
    n, r, v = 3000, 0, 4
    all_sprites = pygame.sprite.Group()
    pygame.time.set_timer(TARELKA_EVENT, n, 25)
    Tarelka(all_sprites)

    running = True

    while running:

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
            if event.type == pygame.MOUSEBUTTONDOWN:
                all_sprites.update(event)
            if event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
                screens.pausa(WIDTH, HEIGHT, screen)
                pygame.mixer.music.play(-1)
            if event.type == TARELKA_EVENT:
                r += 1
                if r in [5, 10, 13, 15, 20, 23, 25]:
                    BigTarelka(all_sprites)
                    n -= 1000
                    v -= 1
                elif r in [3, 17]:
                    x = 90
                    Tarelka(all_sprites, x)
                    Tarelka(all_sprites, x + 350)
                elif r == 23:
                    x = 20
                    BigTarelka(all_sprites, x)
                    BigTarelka(all_sprites, x + 370)
                else:
                    Tarelka(all_sprites)
            if r >= 25:
                screens.final_screen(count, WIDTH, HEIGHT, screen, True)
                count = 0  # появляется окно "вы победили. следующий уровень. пройти уровень снова"
        fon = pygame.transform.scale(load_image('background_main.jpg'),
                                     (WIDTH, HEIGHT))
        screen.blit(fon, (0, 0))

        all_sprites.draw(screen)
        all_sprites1.draw(screen)
        all_sprites.update()
        pygame.time.delay(v)
        pygame.display.flip()

        font = pygame.font.Font(None, 450)
        t = font.render(str(count), True, pygame.Color('black'))
        screen.blit(t, (0, 0))

    terminate()
Ejemplo n.º 2
0
 def update(self, *args):
     global count
     if not pygame.sprite.collide_mask(self, city):
         self.rect = self.rect.move(0, 1)
     else:
         screens.final_screen(
             count, WIDTH, HEIGHT, screen, False
         )  # вывод сообщения о проигрыше. выбор главное меню или повторить уровень
     if args and args[0].type == pygame.MOUSEBUTTONDOWN and \
             self.rect.collidepoint(args[0].pos):
         sound_boom.play()
         Tarelka.kill(self)
         count += 10