Exemple #1
0
def draw_move_board():
    mg.window.fill(mg.color_scheme["background_color"])
    board_pixel_width = mg.width * 17 / 20
    board_pixel_height = mg.height
    board_columns = mg.settings["board_width"]
    board_rows = mg.settings["board_height"]
    cell_dim = min(board_pixel_height/board_rows, board_pixel_width/board_columns)
    for i in range(1, board_columns):
        pygame.draw.line(mg.window, mg.color_scheme["text_color"],
                         (cell_dim * i, 1),
                         (cell_dim * i, cell_dim * board_rows), 3)
    for i in range(1, board_rows):
        pygame.draw.line(mg.window, mg.color_scheme["text_color"],
                         (1, cell_dim * i),
                         (cell_dim * board_columns, cell_dim * i), 3)
    pygame.draw.line(mg.window, mg.color_scheme["text_color"],
                     (1, 1), (1, cell_dim * board_rows), 3)
    pygame.draw.line(mg.window, mg.color_scheme["text_color"],
                     (1, 1), (cell_dim * board_columns, 1), 3)
    pygame.draw.line(mg.window, mg.color_scheme["text_color"],
                     (1, cell_dim * board_rows), (cell_dim * board_columns, cell_dim * board_rows), 3)
    pygame.draw.line(mg.window, mg.color_scheme["text_color"],
                     (cell_dim * board_columns, 1), (cell_dim * board_columns, cell_dim * board_rows), 3)
    mg.draw_button(mg.width * 17 / 20, mg.height * 17 / 20,
                   mg.width * 2 / 20, mg.height * 2 / 20, "Back")
    pygame.display.update()
def draw_play_board():
    mg.window.fill(mg.color_scheme["background_color"])
    board_columns = board_width
    board_rows = board_height
    for i in range(1, board_columns):
        pygame.draw.line(mg.window, mg.color_scheme["text_color"],
                         (cell_dim * i, 1),
                         (cell_dim * i, cell_dim * board_rows), 3)
    for i in range(1, board_rows):
        pygame.draw.line(mg.window, mg.color_scheme["text_color"],
                         (1, cell_dim * i),
                         (cell_dim * board_columns, cell_dim * i), 3)
    pygame.draw.line(mg.window, mg.color_scheme["text_color"], (1, 1),
                     (1, cell_dim * board_rows), 3)
    pygame.draw.line(mg.window, mg.color_scheme["text_color"], (1, 1),
                     (cell_dim * board_columns, 1), 3)
    pygame.draw.line(mg.window, mg.color_scheme["text_color"],
                     (1, cell_dim * board_rows),
                     (cell_dim * board_columns, cell_dim * board_rows), 3)
    pygame.draw.line(mg.window, mg.color_scheme["text_color"],
                     (cell_dim * board_columns, 1),
                     (cell_dim * board_columns, cell_dim * board_rows), 3)
    mg.draw_button(mg.width * 17 / 20, mg.height * 17 / 20, mg.width * 2 / 20,
                   mg.height * 2 / 20, "Back")
    pygame.display.update()
def game_finish_prompt(human_won, text):
    winner = ""
    if human_won:
        winner = "Human"
    else:
        winner = "AI"
    font = pygame.freetype.SysFont("Arial", 14)
    mg.draw_button(board_pixel_width * 4 / 10, board_pixel_height * 3 / 10,
                   board_pixel_width * 2 / 10, board_pixel_height / 10,
                   winner + " Won!")
    mg.draw_custom_font_button(board_pixel_width * 3 / 10,
                               board_pixel_height * 4 / 10,
                               board_pixel_width * 4 / 10,
                               board_pixel_height / 10, text, font, 14)
    pygame.display.update()
Exemple #4
0
def draw_main_menu():
    mg.window.fill(mg.color_scheme["background_color"])
    mg.draw_button(mg.width * 2 / 5, mg.height * 2 / 16, mg.width / 5, mg.height * 2 / 16, "Play")
    mg.draw_button(mg.width * 2 / 5, mg.height * 6 / 16, mg.width / 5, mg.height * 2 / 16, "Settings")
    mg.draw_button(mg.width * 2 / 5, mg.height * 10 / 16, mg.width / 5, mg.height * 2 / 16, "Exit")
    pygame.display.update()
Exemple #5
0
def draw_settings_menu():
    mg.window.fill(mg.color_scheme["background_color"])
    width_proportion = mg.width / 20
    height_proportion = mg.height / 20
    mg.draw_button(width_proportion * 17, height_proportion * 17,
                   width_proportion * 2, height_proportion * 2, "Back")
    mg.draw_button(width_proportion * 2, height_proportion * 3,
                   width_proportion * 4, height_proportion * 2, "Board width: " + str(mg.settings["board_width"]))
    mg.draw_button(width_proportion * 2, height_proportion * 6,
                   width_proportion * 4, height_proportion * 2, "Board height: " + str(mg.settings["board_height"]))
    mg.draw_button(width_proportion * 2, height_proportion * 9,
                   width_proportion * 4, height_proportion * 2, "Minimax depth: " + str(mg.settings["minimax_depth"]))
    mg.draw_button(width_proportion * 2, height_proportion * 12,
                   width_proportion * 4, height_proportion * 2,
                   "Moves per turn : " + str(mg.settings["moves_per_turn"]))
    mg.draw_button(width_proportion * 2, height_proportion * 15,
                   width_proportion * 4, height_proportion * 2, "No. of pieces: " + str(mg.settings["number_of_pieces"]))
    mg.draw_button(width_proportion * 12, height_proportion * 3,
                   width_proportion * 6, height_proportion * 2, "Define Moves")
    mg.draw_button(width_proportion * 12, height_proportion * 6,
                   width_proportion * 6, height_proportion * 2, "Define Score Function")
    mg.draw_button(width_proportion * 12, height_proportion * 9,
                   width_proportion * 6, height_proportion * 2, "Define Board")
    mg.draw_button(width_proportion * 12, height_proportion * 12,
                   width_proportion * 6, height_proportion * 2, "Define Win Condition")
    pygame.display.update()