Пример #1
0
def initialize_board(screen, player1, player2, against):
    """
    To initialize the board.
    """
    screen.fill(screenfill)
    srect = pygame.Rect(0, 5, hsize, 55)
    brect = pygame.Rect(margin_left, margin_top, box_width*3, box_height*3)
    pygame.draw.rect(screen, fill_color, srect)
    pygame.draw.rect(screen, fill_color, brect)
    #buttons
    title = TextInput("Tic-Tac-Toe", hsize//2 - 130, 10, white, 60)
    
    if against == "is_human":
        pl1, pl2 = "Player 1", "Player 2"
    elif against == "is_random":
        pl1, pl2 = "Player", "Random agent"
    elif against == "is_ai":
        pl1, pl2 = "Player", "AI agent"
        
    players_def1 = Button(pl1 +" - " + player1, hsize//2-300, 100, white, 36, fill_color)
    
    players_def2 = Button(pl2+" - " + player2, hsize//2+120, 100, white, 36, fill_color)    
    
    #vertical and horizontal lines
    pygame.draw.line(screen, white, (margin_left, margin_top+box_height), (hsize-margin_right, margin_top+box_height), 5)
    pygame.draw.line(screen, white, (margin_left, margin_top+box_height*2), (hsize-margin_right, margin_top+box_height*2), 5)
    pygame.draw.line(screen, white, (margin_left+box_width, margin_top), (margin_left+box_width, vsize-margin_bottom), 5)
    pygame.draw.line(screen, white, (hsize-margin_right-box_width, margin_top), (hsize-margin_right-box_width, vsize-margin_bottom), 5)
    
    title.add_text(screen)
    players_def1.add_button(screen)
    players_def2.add_button(screen)    
    return screen
Пример #2
0
def screen3(text="Generated Plots"):
    screen.fill((250, 250, 250))
    screen.blit(icon, (10, 10))
    tex = TextInput(text, 100, 250, blue)
    tex.add_text(screen)
    back.add_button(screen)
    title.add_button(screen)
Пример #3
0
def screen2(text="Generated Plots"):
    screen.fill((250, 250, 250))
    screen.blit(icon, (10, 10))
    screen.blit(plots, (80, 220))
    pspace.add_button(screen)
    ptime.add_button(screen)
    pspacetime.add_button(screen)
    back.add_button(screen)
    tex = TextInput(text, 50, 180, blue)
    tex2 = TextInput("Select a plot to view: ", 50, 750, blue)
    tex.add_text(screen)
    tex2.add_text(screen)
    title.add_button(screen)
Пример #4
0
def screen1(text="Enter reservoir properties: "):
    screen.fill((250, 250, 250))
    screen.blit(icon, (10, 10))
    rec = pygame.Rect(left_margin, top_margin - 10,
                      win_width - left_margin * 2,
                      win_height - top_margin * 1.15)
    pygame.draw.rect(screen, (10, 10, 200), rec, border_radius=25)
    solve.add_button(screen)
    clear.add_button(screen)
    tex = TextInput(text, 150, 150, blue)
    tex.add_text(screen)
    title.add_button(screen)
    add_texts(screen, texts)
    add_textboxes(screen, boxes)
Пример #5
0
        pygame.display.flip()                


def loop1():
    first_screen(screen)
    while 1:
        for event in pygame.event.get():
            if event.type == pygame.MOUSEBUTTONUP:
                pos = pygame.mouse.get_pos()
                
                if versus_ra.rect.collidepoint(pos):
                        screen.fill((250, 250, 250))
                        title.add_button(screen)
                        Xbutton.add_button(screen)
                        Obutton.add_button(screen)
                        choose.add_text(screen) 
                        loop_select("is_random")
                        
                if versus_hu.rect.collidepoint(pos):
                                player1, player2 = "X", "O"
                                cplayer = choice([player1, player2])
                                p1 = Player(player1)
                                p2 = Player(player2)
                                is_human(p1, p2, cplayer)                    
                        
        pygame.display.flip()


def loop_select(against):
    while 1:
        for event in pygame.event.get():