Ejemplo n.º 1
0
def main_loop(survivor, clock):
    total_frames = 0
    while survivor.health > 0:
        Tile.draw_all(display)
        interaction(display, survivor)
        Zombie.spawn(display, total_frames, survivor)
        survivor.movement()
        text(display, survivor.health, Zombie.left_round + len(Zombie.instances),
             clock.get_fps(), Zombie.level, survivor.ammo, Drop.actives)
        Bullet.update(display)
        survivor.draw(display)
        Zombie.update(display, survivor)
        PickUp.update(display, survivor, total_frames)
        Drop.update(display, survivor)
        clock.tick(Options.fps)
        pygame.display.flip()
        total_frames += 1
Ejemplo n.º 2
0
        if e.type == pygame.KEYDOWN:
            if e.key == pygame.K_ESCAPE:
                game.menu()

    drawScreen()
    #ЕТО очки
    text = font.render("Score: " + str(score), True, (200, 150, 250))
    screen.blit(text, [700, 100])
    text1 = font.render("Life: " + str(life), True, (200, 150, 250))
    screen.blit(text1, [700, 200])
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit_program = True

    if not game_over:
        student.update()
        player.update()
        bon.update()
        sar = ball.update()
        if sar == True:
            life -= 1
            sar = False
        if life == 0:
            game_over = True
    if game_over:
        text = font.render("Game Over", True, white)
        textpos = text.get_rect(centerx=background.get_width() / 2)
        textpos.top = 300
        screen.blit(text, textpos)
    if pygame.sprite.spritecollide(player, balls, False):
        diff = (player.rect.x + player.width / 2) - (ball.rect.x +
Ejemplo n.º 3
0
                game.start()
                last_time = time.time()*1000
            elif event.type == pygame.KEYDOWN:
                #print(event.key)
                key_monitor.key_down(event)
            elif event.type == pygame.KEYUP:
                key_monitor.key_up(event)

        # Game loop
        if game.started() and (time.time()*1000.0)-last_time > FRAME_TIME:
            last_time = time.time()*1000.0
            game.tick()
            key_monitor.tick()

            witch.update()
            zombie.update()
            monster.update()
            skeleton.update()

            witch.move(SPEED)
            zombie.move(SPEED)
            monster.move(SPEED)
            skeleton.move(SPEED)

            screen.fill(black)

            game.check_piece([witch,zombie,monster,skeleton], key_monitor)

            game.draw_background(screen)

            screen.blit(witch.get_image(), witch.get_rect())