def begin(result, steps_machine, steps_user):
    time.sleep(1)
    screen_size = (400, 150)
    screen = pygame.display.set_mode(screen_size)
    pygame.display.set_caption(result)
    pygame.font.init()  # you have to call this at the start,
    # if you want to use this module.
    my_font = pygame.font.SysFont('bold', 80)
    result_font = pygame.font.SysFont('bold', 22)
    steps_font = pygame.font.SysFont('bold', 25)

    start_button_skin = pygame.Surface((100, 35))
    start_button_skin.fill((255, 255, 255))
    start_count = 0
    clock = pygame.time.Clock()
    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                exit()
            elif event.type == MOUSEBUTTONDOWN:
                if pygame.mouse.get_pos()[0] >= 286 and pygame.mouse.get_pos(
                )[1] >= 124:
                    if pygame.mouse.get_pos(
                    )[0] <= 384 and pygame.mouse.get_pos()[1] <= 146:
                        start_game.start()
        pygame.display.update()
        screen.fill((150, 65, 200))
        text_surface = my_font.render(result, False, (255, 255, 255))
        if steps_machine != steps_user:
            if steps_machine == 1:
                text2_surface = steps_font.render(
                    'Encontrei em ' + str(steps_machine) + ' passo,', False,
                    (255, 255, 255))
            else:
                text2_surface = steps_font.render(
                    'Encontrei em ' + str(steps_machine) + ' passos,', False,
                    (255, 255, 255))
            text3_surface = steps_font.render(
                'você encontrou em ' + str(steps_user) + '.', False,
                (255, 255, 255))
            screen.blit(text2_surface, (75, 110))
            screen.blit(text3_surface, (75, 125))
        start_text_surface = result_font.render("PLAY AGAIN", False,
                                                (255, 0, 0))
        screen.blit(text_surface, (20, 20))
        screen.blit(start_button_skin, (286, 125))

        if start_count > 100:
            screen.blit(start_text_surface, (290, 130))
        if start_count > 200:
            start_count = 0
        start_count += 1

        clock.tick(120)
Esempio n. 2
0
def begin():
    pygame.init()

    init_sound = pygame.mixer.Sound("snd/init.wav")
    init_sound.play(-1)

    screen_size = (710, 512)
    screen = pygame.display.set_mode(screen_size)
    pygame.display.set_caption('Heap Sort')
    pygame.font.init()  # you have to call this at the start,
    # if you want to use this module.
    my_font = pygame.font.SysFont('bold', 80)
    start_font = pygame.font.SysFont('bold', 22)

    start_button_skin = pygame.Surface((50, 35))
    start_button_skin.fill((255, 255, 255))
    start_count = 0
    clock = pygame.time.Clock()

    # INSTRUCTIONS
    ins_font = pygame.font.SysFont('bold', 50)
    ins_texts = []
    ins_texts.append(
        ins_font.render("Será feita a ordenação de 15 valores", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("por meio do algoritmo Heap Sort", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("É possível visualizar no topo o vetor", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("original criado de forma aleatória,", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("ao centro o Max Heap de cada iteração", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("e logo abaixo o vetor ordenado", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("adicionando a raiz do Heap a cada passo.", False,
                        (255, 255, 255)))

    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                exit()
            elif event.type == MOUSEBUTTONDOWN:
                if pygame.mouse.get_pos()[0] >= 600 and pygame.mouse.get_pos(
                )[1] >= 390:
                    if pygame.mouse.get_pos(
                    )[0] <= 647 and pygame.mouse.get_pos()[1] <= 425:
                        init_sound.stop()
                        start_game.start()
        pygame.display.update()
        screen.fill((150, 65, 200))
        text_surface = my_font.render("Heap Sort", False, (255, 255, 255))
        start_text_surface = start_font.render("START", False, (255, 0, 0))
        screen.blit(text_surface, (80, 10))
        screen.blit(start_button_skin, (599, 390))
        #SHOW INSTRUCTIONS:
        #image = pygame.image.load('img/game.png')
        #image = pygame.transform.scale(image, (440, 320))
        pos_y = 60
        i = 1
        for ins in ins_texts:
            screen.blit(ins, (20, pos_y))
            if i == 2:
                pos_y += 20
            i += 1
            pos_y += 40
        #screen.blit(image, (130,120))
        #screen.blit(ins_texts[-1], (100, 442))
        if start_count > 100:
            screen.blit(start_text_surface, (600, 400))
        if start_count > 200:
            start_count = 0
        start_count += 1

        clock.tick(120)
Esempio n. 3
0
from src import start_game
from src import first_screen
first_screen.begin()
start_game.start()
Esempio n. 4
0
def begin():
    pygame.init()

    init_sound = pygame.mixer.Sound("snd/init.wav")
    init_sound.play(-1)

    screen_size = (710, 512)
    screen = pygame.display.set_mode(screen_size)
    pygame.display.set_caption('Red Black Tree')
    pygame.font.init()  # you have to call this at the start,
    # if you want to use this module.
    my_font = pygame.font.SysFont('bold', 80)
    start_font = pygame.font.SysFont('bold', 22)

    start_button_skin = pygame.Surface((50, 35))
    start_button_skin.fill((255, 255, 255))
    start_count = 0
    clock = pygame.time.Clock()

    # INSTRUCTIONS
    ins_font = pygame.font.SysFont('bold', 50)
    ins_texts = []
    ins_texts.append(
        ins_font.render("Será feita a inserção e remoção de até 15 ", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("valores em uma Red Black Tree.", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("Será inserido o valor informado, ou um", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("aleatório se não for informado valor.", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("Clique sobre a carta na parte superior", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("para removê-la. Serão informados os ", False,
                        (255, 255, 255)))
    ins_texts.append(
        ins_font.render("casos de inserção de cada valor.", False,
                        (255, 255, 255)))

    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                exit()
            elif event.type == MOUSEBUTTONDOWN:
                if pygame.mouse.get_pos()[0] >= 600 and pygame.mouse.get_pos(
                )[1] >= 390:
                    if pygame.mouse.get_pos(
                    )[0] <= 647 and pygame.mouse.get_pos()[1] <= 425:
                        init_sound.stop()
                        start_game.start()
        pygame.display.update()
        screen.fill((150, 65, 200))
        text_surface = my_font.render("Red Black Tree", False, (255, 255, 255))
        start_text_surface = start_font.render("START", False, (255, 0, 0))
        screen.blit(text_surface, (80, 10))
        screen.blit(start_button_skin, (599, 390))
        #SHOW INSTRUCTIONS:
        #image = pygame.image.load('img/game.png')
        #image = pygame.transform.scale(image, (440, 320))
        pos_y = 60
        i = 1
        for ins in ins_texts:
            screen.blit(ins, (20, pos_y))
            if i == 2:
                pos_y += 20
            i += 1
            pos_y += 40
        #screen.blit(image, (130,120))
        #screen.blit(ins_texts[-1], (100, 442))
        if start_count > 100:
            screen.blit(start_text_surface, (600, 400))
        if start_count > 200:
            start_count = 0
        start_count += 1

        clock.tick(120)