diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/bassill-lee-stanton-littlefield.iml b/.idea/bassill-lee-stanton-littlefield.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/bassill-lee-stanton-littlefield.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0bbcf41 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..d7d145b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Main_Board.py b/Main_Board.py index b6dcd70..7c806e9 100644 --- a/Main_Board.py +++ b/Main_Board.py @@ -4,7 +4,7 @@ """ import pygame -from constants import BLACK, ROWS, RED, SQUARE_SIZE, COLS, WHITE +from constants import BLACK, ROWS, RED, SQUARE_SIZE, COLS, WHITE, GREEN from pieces import Piece class Main_Board: @@ -13,12 +13,14 @@ class Main_Board: evaluate the board, get all pieces, get a single piece, move a piece (left or right), create the board, draw the board, remove a piece, and check for a winner. """ - def __init__(self, color): + def __init__(self, color, user_color, user_two_color): """ The init function initializes the Main_Board class with a color and creates the board. """ self.board = [] self.color = color + self.user_color = user_color + self.user_two_color = user_two_color self.red_left = self.white_left = 12 self.red_kings = self.white_kings = 0 self.create_board() @@ -57,7 +59,7 @@ def move(self, piece, row, col): piece.move(row, col) if row == ROWS - 1 or row == 0: piece.make_king() - if piece.color == WHITE: + if piece.color == self.user_two_color: self.white_kings += 1 else: self.red_kings += 1 @@ -80,9 +82,9 @@ def create_board(self): for col in range(COLS): if col % 2 == ((row + 1) % 2): if row < 3: - self.board[row].append(Piece(row, col, WHITE)) + self.board[row].append(Piece(row, col, self.user_two_color)) elif row > 4: - self.board[row].append(Piece(row, col, RED)) + self.board[row].append(Piece(row, col, self.user_color)) else: self.board[row].append(0) else: @@ -106,7 +108,7 @@ def remove(self, pieces): for piece in pieces: self.board[piece.row][piece.col] = 0 if piece != 0: - if piece.color == RED: + if piece.color == self.user_color: self.red_left -= 1 else: self.white_left -= 1 @@ -116,10 +118,10 @@ def winner(self): The winner function checks if a winner has been found and returns the winner. If no winner has been found, None is returned. If a user has no pieces left or no moves left, the other user is the winner. """ - if self.red_left <= 0 or self.no_moves(RED): - return WHITE - elif self.white_left <= 0 or self.no_moves(WHITE): - return RED + if self.red_left <= 0 or self.no_moves(self.user_color): + return self.user_two_color + elif self.white_left <= 0 or self.no_moves(self.user_two_color): + return self.user_color return None @@ -131,10 +133,10 @@ def get_valid_moves(self, piece): left = piece.col - 1 right = piece.col + 1 row = piece.row - if piece.color == RED or piece.king: + if piece.color == self.user_color or piece.king: moves.update(self.move_left(row -1, max(row-3, -1), -1, piece.color, left)) moves.update(self.move_right(row -1, max(row-3, -1), -1, piece.color, right)) - if piece.color == WHITE or piece.king: + if piece.color == self.user_two_color or piece.king: moves.update(self.move_left(row +1, min(row+3, ROWS), 1, piece.color, left)) moves.update(self.move_right(row +1, min(row+3, ROWS), 1, piece.color, right)) diff --git a/SecondMenu.py b/SecondMenu.py index efe27dc..e266e2c 100644 --- a/SecondMenu.py +++ b/SecondMenu.py @@ -46,6 +46,8 @@ def __init__(self, track): self.background_music = BackgroundMusic([track]) color = RED + user_color = RED + user_two_color = WHITE def start_game_menu(self): """ The start game menu function displays the second menu of the game, which allows the user to choose between playing against another player or against the computer. @@ -193,7 +195,7 @@ def start_game_vs_player(self, screen): """ run = True clock = pygame.time.Clock() - game = Game(screen, self.color, player1_name.username, player2_name.username) + game = Game(screen, self.color, self.user_color, self.user_two_color, player1_name.username, player2_name.username) global score_manager, user_scores # Exit Button @@ -209,12 +211,12 @@ def start_game_vs_player(self, screen): if game.winner() != None: print(game.winner()) run = False - if game.winner() == RED: + if game.winner() == self.user_color: player1_name.update_win() score_manager.update_scores(player1_name) player2_name.update_loss() score_manager.update_scores(player2_name) - elif game.winner() == WHITE: + elif game.winner() == self.user_two_color: player2_name.update_win() score_manager.update_scores(player2_name) player1_name.update_loss() @@ -240,7 +242,7 @@ def start_game_vs_computer(self, screen): """ run = True clock = pygame.time.Clock() - game = Game(screen, self.color, player1_name.username, "Computer") + game = Game(screen, self.color, self.user_color, self.user_two_color, player1_name.username, "Computer") global score_manager, user_scores # Exit Button @@ -253,8 +255,8 @@ def start_game_vs_computer(self, screen): while run: clock.tick(60) - if game.turn == WHITE: - value, new_board = minimax(game.get_board(), 4, WHITE, game) + if game.turn == self.user_two_color: + value, new_board = minimax(game.get_board(), 4, self.user_two_color, game, self.user_color, self.user_two_color) game.ai_move(new_board) if game.winner() != None: diff --git a/__pycache__/Main_Board.cpython-311.pyc b/__pycache__/Main_Board.cpython-311.pyc index a4f5bc8..a1aeb96 100644 Binary files a/__pycache__/Main_Board.cpython-311.pyc and b/__pycache__/Main_Board.cpython-311.pyc differ diff --git a/__pycache__/MusicClass.cpython-311.pyc b/__pycache__/MusicClass.cpython-311.pyc new file mode 100644 index 0000000..cf166ae Binary files /dev/null and b/__pycache__/MusicClass.cpython-311.pyc differ diff --git a/__pycache__/MusicClass.cpython-312.pyc b/__pycache__/MusicClass.cpython-312.pyc new file mode 100644 index 0000000..9a459ec Binary files /dev/null and b/__pycache__/MusicClass.cpython-312.pyc differ diff --git a/__pycache__/Player.cpython-311.pyc b/__pycache__/Player.cpython-311.pyc index 0737676..95bebc4 100644 Binary files a/__pycache__/Player.cpython-311.pyc and b/__pycache__/Player.cpython-311.pyc differ diff --git a/__pycache__/Player.cpython-312.pyc b/__pycache__/Player.cpython-312.pyc new file mode 100644 index 0000000..0153a20 Binary files /dev/null and b/__pycache__/Player.cpython-312.pyc differ diff --git a/__pycache__/ScoreManager.cpython-311.pyc b/__pycache__/ScoreManager.cpython-311.pyc new file mode 100644 index 0000000..35bf372 Binary files /dev/null and b/__pycache__/ScoreManager.cpython-311.pyc differ diff --git a/__pycache__/ScoreManager.cpython-312.pyc b/__pycache__/ScoreManager.cpython-312.pyc new file mode 100644 index 0000000..8612352 Binary files /dev/null and b/__pycache__/ScoreManager.cpython-312.pyc differ diff --git a/__pycache__/SecondMenu.cpython-311.pyc b/__pycache__/SecondMenu.cpython-311.pyc index e45cdb0..26ac09c 100644 Binary files a/__pycache__/SecondMenu.cpython-311.pyc and b/__pycache__/SecondMenu.cpython-311.pyc differ diff --git a/__pycache__/SharedObjects.cpython-311.pyc b/__pycache__/SharedObjects.cpython-311.pyc new file mode 100644 index 0000000..abc2e00 Binary files /dev/null and b/__pycache__/SharedObjects.cpython-311.pyc differ diff --git a/__pycache__/SharedObjects.cpython-312.pyc b/__pycache__/SharedObjects.cpython-312.pyc new file mode 100644 index 0000000..adffd63 Binary files /dev/null and b/__pycache__/SharedObjects.cpython-312.pyc differ diff --git a/__pycache__/computer.cpython-311.pyc b/__pycache__/computer.cpython-311.pyc index 0635045..39016ae 100644 Binary files a/__pycache__/computer.cpython-311.pyc and b/__pycache__/computer.cpython-311.pyc differ diff --git a/__pycache__/computer.cpython-312.pyc b/__pycache__/computer.cpython-312.pyc new file mode 100644 index 0000000..0829162 Binary files /dev/null and b/__pycache__/computer.cpython-312.pyc differ diff --git a/__pycache__/constants.cpython-311.pyc b/__pycache__/constants.cpython-311.pyc index ffc1ec2..f4b376b 100644 Binary files a/__pycache__/constants.cpython-311.pyc and b/__pycache__/constants.cpython-311.pyc differ diff --git a/__pycache__/constants.cpython-312.pyc b/__pycache__/constants.cpython-312.pyc new file mode 100644 index 0000000..dc0b6a1 Binary files /dev/null and b/__pycache__/constants.cpython-312.pyc differ diff --git a/__pycache__/game.cpython-311.pyc b/__pycache__/game.cpython-311.pyc index 0a59e9c..791948e 100644 Binary files a/__pycache__/game.cpython-311.pyc and b/__pycache__/game.cpython-311.pyc differ diff --git a/__pycache__/pieces.cpython-311.pyc b/__pycache__/pieces.cpython-311.pyc index 174e8c4..98f1424 100644 Binary files a/__pycache__/pieces.cpython-311.pyc and b/__pycache__/pieces.cpython-311.pyc differ diff --git a/__pycache__/pieces.cpython-312.pyc b/__pycache__/pieces.cpython-312.pyc new file mode 100644 index 0000000..eb5bdee Binary files /dev/null and b/__pycache__/pieces.cpython-312.pyc differ diff --git a/computer.py b/computer.py index c54ff82..71151b1 100644 --- a/computer.py +++ b/computer.py @@ -9,7 +9,7 @@ import pygame from constants import RED, WHITE -def minimax(position, depth, max_player, game): +def minimax(position, depth, max_player, game, user_color, user_two_color): """ The minimax function is the minimax algorithm for AI to play checkers, and has parameters position, depth, max_player, and game parameters. The function returns the best move for the computer to make. @@ -21,8 +21,8 @@ def minimax(position, depth, max_player, game): if max_player: maxEval = float('-inf') best_move = None - for move in get_all_moves(position, WHITE, game): - evaluation = minimax(move, depth-1, False, game)[0] + for move in get_all_moves(position, user_two_color, game): + evaluation = minimax(move, depth-1, False, game, user_color, user_two_color)[0] maxEval = max(maxEval, evaluation) if maxEval == evaluation: best_move = move @@ -31,8 +31,8 @@ def minimax(position, depth, max_player, game): else: minEval = float('inf') best_move = None - for move in get_all_moves(position, RED, game): - evaluation = minimax(move, depth-1, True, game)[0] + for move in get_all_moves(position, user_color, game): + evaluation = minimax(move, depth-1, True, game, user_color, user_two_color)[0] minEval = min(minEval, evaluation) if minEval == evaluation: best_move = move diff --git a/game.py b/game.py index af2a738..9624aa4 100644 --- a/game.py +++ b/game.py @@ -3,7 +3,7 @@ The game file holds the game logic and game class. """ import pygame -from constants import RED, WHITE, YELLOW, SQUARE_SIZE +from constants import RED, WHITE, YELLOW, SQUARE_SIZE, GREEN from Main_Board import Main_Board class Game: @@ -12,7 +12,7 @@ class Game: display the piece count, display the player names, update the board, check for a winner, select a piece, move a piece, show available moves, change the turn, get the board, and move an AI piece. """ - def __init__(self, win, color, player1, player2): + def __init__(self, win, color, user_color, user_two_color, player1, player2): """ The init function initializes the Game class with a window, color, player1, and player2, and sets the turn start time and turn timeout. The text color is set to white, and the urgent text color is set to red. The screen is set to the window size, and the player names are set to player1 and player2. @@ -21,9 +21,11 @@ def __init__(self, win, color, player1, player2): self.turn_timeout = 5200 # 5.2 seconds per turn self.win = win self.color = color + self.user_color = user_color + self.user_two_color = user_two_color self.selected = None - self.board = Main_Board(self.color) - self.turn = RED + self.board = Main_Board(self.color, self.user_color, user_two_color) + self.turn = user_color self.valid_moves = {} self.font = pygame.font.Font(None, 36) # Font for rendering text self.text_color = WHITE # Text color @@ -53,10 +55,10 @@ def display_turn(self): """ The display turn function displays the current turn on the screen. """ - if self.turn == RED: - text = f"Current Turn: RED" + if self.turn == self.user_color: + text = f"Current Turn: Player One" else: - text = f"Current Turn: WHITE" + text = f"Current Turn: Player Two" text_surface = self.font.render(text, True, self.text_color) self.screen.blit(text_surface, (715, 100)) @@ -151,10 +153,10 @@ def change_turn(self): """ self.valid_moves = {} self.turn_start_time = pygame.time.get_ticks() # Reset the turn timer - if self.turn == RED: - self.turn = WHITE + if self.turn == self.user_color: + self.turn = self.user_two_color else: - self.turn = RED + self.turn = self.user_color def get_board(self): """ diff --git a/main.py b/main.py index d7bbf32..585c257 100644 --- a/main.py +++ b/main.py @@ -4,23 +4,28 @@ """ import pygame +import redditwarp.SYNC +# from redditwarp.models.submission_SYNC import Submission as Submission_IO +# from redditwarp.models.submission import Submission +import textwrap from SecondMenu import SecondMenu -from constants import BLUE, YELLOW, RED, GREEN +from constants import BLUE, YELLOW, RED, GREEN, BLACK, WHITE, GREY from ScoreManager import ScoreManager from SecondMenu import SecondMenu - pygame.init() -pygame.mixer.init() # initialize pygame mixer for music +pygame.mixer.init() # initialize pygame mixer for music # set up the drawing window -Width, Height = 1000, 700 # updated size +Width, Height = 1000, 700 # updated size screen = pygame.display.set_mode([Width, Height]) -#title of the game for screen +# title of the game for screen pygame.display.set_caption("Checkers+") # background music -tracks = ["music/Track1.mp3", "music/Track2.mp3", "music/Track3.mp3", "music/Track4.mp3", "music/Track5.mp3", "music/Track6.mp3", "music/Track7.mp3", "music/Track8.mp3"] # can add more or delete tracks if we do not like them +tracks = ["music/Track1.mp3", "music/Track2.mp3", "music/Track3.mp3", "music/Track4.mp3", "music/Track5.mp3", + "music/Track6.mp3", "music/Track7.mp3", + "music/Track8.mp3"] # can add more or delete tracks if we do not like them current_track = 0 SONG_END = pygame.USEREVENT + 1 second_menu = SecondMenu(tracks) @@ -32,12 +37,13 @@ def music_loop(): """ global current_track pygame.mixer.music.load(tracks[current_track]) - pygame.mixer.music.set_volume(0.1) # 0.1-1.0 + pygame.mixer.music.set_volume(0.1) # 0.1-1.0 pygame.mixer.music.play() current_track = (current_track + 1) % len(tracks) + music_loop() -pygame.mixer.music.set_endevent(SONG_END) # create event for song ending/looping +pygame.mixer.music.set_endevent(SONG_END) # create event for song ending/looping # title for display game_title = "Checkers+" @@ -45,7 +51,7 @@ def music_loop(): credits1 = "Developed by Wander Cerda-Torres, Barry Lin," credits2 = "Nathan McCourt, Jonathan Stanczak, and Geonhee Yu" background_image = pygame.image.load("checkers.jpg") -background_image = pygame.transform.scale(background_image, (Width, Height)) +background_image = pygame.transform.scale(background_image, (Width, Height)) title_font = pygame.font.Font(None, 64) message_font = pygame.font.Font(None, 32) credits_font = pygame.font.Font(None, 25) @@ -63,6 +69,8 @@ def music_loop(): credits_rect2 = credits_text2.get_rect(center=(Width // 2, 670)) second_menu_instance = SecondMenu(tracks) + + def main(): """ The main function is the main menu of the game. It displays the title, message, and credits, and holds user interaction with buttons. @@ -77,32 +85,36 @@ def main(): running = False elif event.type == pygame.MOUSEBUTTONDOWN: buttons = menu_buttons() - if buttons[0].collidepoint(event.pos): # If Start Game button is clicked, show the second menu - second_menu_instance.start_game_menu() - if buttons[2].collidepoint(event.pos): # if mouse is clicked on tutorial button + if buttons[0].collidepoint(event.pos): # If Start Game button is clicked, show the second menu + second_menu_instance.start_game_menu() + if buttons[2].collidepoint(event.pos): # if mouse is clicked on tutorial button tutorial() - elif buttons[1].collidepoint(event.pos): # if mouse is clicked on settings button + elif buttons[1].collidepoint(event.pos): # if mouse is clicked on settings button settings() - elif buttons[4].collidepoint(event.pos): # if mouse is clicked on leaderboard button (not yet implemented) + elif buttons[4].collidepoint( + event.pos): # if mouse is clicked on leaderboard button (not yet implemented) board_customization() + elif buttons[5].collidepoint(event.pos): + templenews(); # Check if the current song has finished, loop to next song elif event.type == SONG_END: music_loop() - #image of the background + # image of the background screen.blit(background_image, (0, 0)) # display title information and credits screen.blit(title_text, title_rect) screen.blit(message_text, message_rect) screen.blit(credits_text1, credits_rect1) screen.blit(credits_text2, credits_rect2) - + menu_buttons() pygame.display.flip() # done! time to quit pygame.quit() + def menu_buttons(): """ The menu buttons function creates the buttons on the main menu. It returns the button rectangles for each button so that they can be used in the main function. @@ -116,29 +128,30 @@ def menu_buttons(): startgame_icon = pygame.image.load('pics/start_icon.png') # Draw the icon next to the text with the specified size startgame_icon_resized = pygame.transform.scale(startgame_icon, icon_size) - startgame_icon_rect = startgame_icon_resized.get_rect(topleft=(Width // 2 - 150 + 10, Height // 3 + (button_height - icon_size[1] - 50) // 2)) + startgame_icon_rect = startgame_icon_resized.get_rect( + topleft=(Width // 2 - 150 + 10, Height // 4 + (button_height - icon_size[1] - 50) // 2)) - color = (128, 128, 128) # grey - cursor_color = (100, 100, 100) # darker grey - position = (Width // 2-150, Height // 3-25) + color = (128, 128, 128) # grey + cursor_color = (100, 100, 100) # darker grey + position = (Width // 2 - 150, Height // 4 - 25) size = (300, 50) # width, height - + button_font = pygame.font.Font(None, 32) - button_text = button_font.render("Start Game", True, (255, 255, 255)) # Button text and color - button_text_rect = button_text.get_rect(center=(Width // 2, Height // 3)) - + button_text = button_font.render("Start Game", True, (255, 255, 255)) # Button text and color + button_text_rect = button_text.get_rect(center=(Width // 2, Height // 4)) + # Create button on screen using position and size parameters pygame.draw.rect(screen, color, pygame.Rect(position, size)) screen.blit(startgame_icon_resized, startgame_icon_rect.topleft) screen.blit(button_text, button_text_rect) - + # Used to indicate if cursor is hovering over button. If so, button will be darker mouse = pygame.mouse.get_pos() button_rect = pygame.Rect(position, size) if button_rect.collidepoint(mouse): pygame.draw.rect(screen, cursor_color, button_rect) # Change color when cursor hovered over else: - pygame.draw.rect(screen, color, button_rect) # stay original color if cursor not hovering over + pygame.draw.rect(screen, color, button_rect) # stay original color if cursor not hovering over screen.blit(button_text, button_text_rect) screen.blit(startgame_icon_resized, startgame_icon_rect.topleft) # Draw the icon after drawing the button @@ -146,15 +159,17 @@ def menu_buttons(): # Settings Button settings_icon = pygame.image.load('pics/settings_icon.png') - position = (Width // 2 - 150, Height // 3 + button_height + spacing) + position = (Width // 2 - 150, Height // 4 + button_height + spacing) size = (300, button_height) # width, height button_text = button_font.render("Settings", True, (255, 255, 255)) # Button text and color - button_text_rect = button_text.get_rect(center=(Width // 2, Height // 3 + button_height + spacing + button_height // 2)) + button_text_rect = button_text.get_rect( + center=(Width // 2, Height // 4 + button_height + spacing + button_height // 2)) # Draw the icon next to the text with the specified size settings_icon_resized = pygame.transform.scale(settings_icon, icon_size) - settings_icon_rect = settings_icon_resized.get_rect(topleft=(Width // 2 - 150 + 10, Height // 3 + button_height + spacing + (button_height - icon_size[1]) // 2)) + settings_icon_rect = settings_icon_resized.get_rect( + topleft=(Width // 2 - 150 + 10, Height // 4 + button_height + spacing + (button_height - icon_size[1]) // 2)) # Create button on screen using position and size parameters pygame.draw.rect(screen, color, pygame.Rect(position, size)) @@ -175,57 +190,59 @@ def menu_buttons(): # Tutorial button tutorial_icon = pygame.image.load('pics/tutorial_icon.png') - color = (128, 128, 128) # grey - cursor_color = (100, 100, 100) # darker grey - position = (Width // 2-150, Height // 3 + 135) + color = (128, 128, 128) # grey + cursor_color = (100, 100, 100) # darker grey + position = (Width // 2 - 150, Height // 4 + 135) size = (300, 50) # width, height button_font = pygame.font.Font(None, 32) - button_text = button_font.render("Tutorial", True, (255, 255, 255)) # Button text and color - button_text_rect = button_text.get_rect(center=(Width // 2, Height // 3+160)) + button_text = button_font.render("Tutorial", True, (255, 255, 255)) # Button text and color + button_text_rect = button_text.get_rect(center=(Width // 2, Height // 4 + 160)) pygame.draw.rect(screen, color, pygame.Rect(position, size)) screen.blit(button_text, button_text_rect) # Draw the icon next to the text with the specified size tutorial_icon_resized = pygame.transform.scale(tutorial_icon, icon_size) - tutorial_icon_rect = tutorial_icon_resized.get_rect(topleft=(Width // 2 - 150 + 10, Height // 3 + 135 + (button_height - icon_size[1]) // 2)) + tutorial_icon_rect = tutorial_icon_resized.get_rect( + topleft=(Width // 2 - 150 + 10, Height // 4 + 135 + (button_height - icon_size[1]) // 2)) pygame.draw.rect(screen, color, pygame.Rect(position, size)) screen.blit(button_text, button_text_rect) - + # Used to indicate if cursor is hovering over button. If so, button will be darker mouse = pygame.mouse.get_pos() button_rect_3 = pygame.Rect(position, size) if button_rect_3.collidepoint(mouse): pygame.draw.rect(screen, cursor_color, button_rect_3) # Change color when cursor hovered over else: - pygame.draw.rect(screen, color, button_rect_3) # stay original color if cursor not hovering over + pygame.draw.rect(screen, color, button_rect_3) # stay original color if cursor not hovering over screen.blit(tutorial_icon_resized, tutorial_icon_rect.topleft) # Draw the icon after drawing the button screen.blit(button_text, button_text_rect) - + # Leaderboard button leaderboard_icon = pygame.image.load('pics/leaderboard_icon.png') - color = (128, 128, 128) # grey - cursor_color = (100, 100, 100) # darker grey - position = (Width // 2 - 150, Height // 3 + 210) # Adjust the vertical position as needed + color = (128, 128, 128) # grey + cursor_color = (100, 100, 100) # darker grey + position = (Width // 2 - 150, Height // 4 + 210) # Adjust the vertical position as needed size = (300, 50) # width, height button_font = pygame.font.Font(None, 32) - button_text = button_font.render("View Rankings", True, (255, 255, 255)) # Button text and color - button_text_rect = button_text.get_rect(center=(Width // 2, Height // 3 + 235)) # Adjust the vertical position as needed + button_text = button_font.render("View Rankings", True, (255, 255, 255)) # Button text and color + button_text_rect = button_text.get_rect( + center=(Width // 2, Height // 4 + 235)) # Adjust the vertical position as needed pygame.draw.rect(screen, color, pygame.Rect(position, size)) screen.blit(button_text, button_text_rect) # Draw the icon next to the text with the specified size leaderboard_icon_resized = pygame.transform.scale(leaderboard_icon, icon_size) leaderboard_icon_rect = leaderboard_icon_resized.get_rect( - topleft=(Width // 2 - 150 + 10, Height // 3 + 210 + (button_height - icon_size[1]) // 2)) + topleft=(Width // 2 - 150 + 10, Height // 4 + 210 + (button_height - icon_size[1]) // 2)) pygame.draw.rect(screen, color, pygame.Rect(position, size)) screen.blit(button_text, button_text_rect) - + # Used to indicate if cursor is hovering over button. If so, button will be darker mouse = pygame.mouse.get_pos() button_rect_4 = pygame.Rect(position, size) @@ -234,7 +251,7 @@ def menu_buttons(): if pygame.mouse.get_pressed()[0]: # Check if left mouse button is clicked show_leaderboard() # Call the function to display the leaderboard else: - pygame.draw.rect(screen, color, button_rect_4) # stay original color if cursor not hovering over + pygame.draw.rect(screen, color, button_rect_4) # stay original color if cursor not hovering over screen.blit(leaderboard_icon_resized, leaderboard_icon_rect.topleft) # Draw the icon after drawing the button screen.blit(button_text, button_text_rect) @@ -242,43 +259,145 @@ def menu_buttons(): # Customize Board button board_icon = pygame.image.load('pics/colorwheel_icon.png') - color = (128, 128, 128) # grey - cursor_color = (100, 100, 100) # darker grey - position = (Width // 2 - 150, Height // 3 + 285) # Adjust the vertical position as needed + color = (128, 128, 128) # grey + cursor_color = (100, 100, 100) # darker grey + position = (Width // 2 - 150, Height // 4 + 285) # Adjust the vertical position as needed size = (300, 50) # width, height button_font = pygame.font.Font(None, 32) - button_text = button_font.render("Customize Board", True, (255, 255, 255)) # Button text and color - button_text_rect = button_text.get_rect(center=(Width // 2, Height // 3 + 310)) # Adjust the vertical position as needed + button_text = button_font.render("Customize Board", True, (255, 255, 255)) # Button text and color + button_text_rect = button_text.get_rect( + center=(Width // 2, Height // 4 + 310)) # Adjust the vertical position as needed pygame.draw.rect(screen, color, pygame.Rect(position, size)) screen.blit(button_text, button_text_rect) # Draw the icon next to the text with the specified size board_icon_resized = pygame.transform.scale(board_icon, icon_size) - board_icon_rect = board_icon_resized.get_rect(topleft=(Width // 2 - 150 + 10, Height // 3 + 285 + (button_height - icon_size[1]) // 2)) + board_icon_rect = board_icon_resized.get_rect( + topleft=(Width // 2 - 150 + 10, Height // 4 + 285 + (button_height - icon_size[1]) // 2)) pygame.draw.rect(screen, color, pygame.Rect(position, size)) screen.blit(button_text, button_text_rect) - + # Used to indicate if cursor is hovering over button. If so, button will be darker mouse = pygame.mouse.get_pos() button_rect_5 = pygame.Rect(position, size) if button_rect_5.collidepoint(mouse): pygame.draw.rect(screen, cursor_color, button_rect_5) # Change color when cursor hovered over else: - pygame.draw.rect(screen, color, button_rect_5) # stay original color if cursor not hovering over + pygame.draw.rect(screen, color, button_rect_5) # stay original color if cursor not hovering over screen.blit(board_icon_resized, board_icon_rect.topleft) # Draw the icon after drawing the button screen.blit(button_text, button_text_rect) - return button_rect, button_rect_2, button_rect_3, button_rect_4, button_rect_5 + # Customize TEMPLE NEWS Button + board_icon = pygame.image.load('pics/Temple.png') + + color = (128, 128, 128) # grey + cursor_color = (100, 100, 100) # darker grey + position = (Width // 2 - 150, Height // 4 + 360) # Adjust the vertical position as needed + size = (300, 50) # width, height + + button_font = pygame.font.Font(None, 32) + button_text = button_font.render("TEMPLE NEWS", True, (255, 255, 255)) # Button text and color + button_text_rect = button_text.get_rect( + center=(Width // 2, Height // 4 + 385)) # Adjust the vertical position as needed + pygame.draw.rect(screen, color, pygame.Rect(position, size)) + screen.blit(button_text, button_text_rect) + + # Draw the icon next to the text with the specified size + board_icon_resized = pygame.transform.scale(board_icon, icon_size) + board_icon_rect = board_icon_resized.get_rect( + topleft=(Width // 2 - 150 + 10, Height // 4 + 360 + (button_height - icon_size[1]) // 2)) + + pygame.draw.rect(screen, color, pygame.Rect(position, size)) + screen.blit(button_text, button_text_rect) + + # Used to indicate if cursor is hovering over button. If so, button will be darker + mouse = pygame.mouse.get_pos() + button_rect_6 = pygame.Rect(position, size) + if button_rect_6.collidepoint(mouse): + pygame.draw.rect(screen, cursor_color, button_rect_6) # Change color when cursor hovered over + else: + pygame.draw.rect(screen, color, button_rect_6) # stay original color if cursor not hovering over + + screen.blit(board_icon_resized, board_icon_rect.topleft) # Draw the icon after drawing the button + screen.blit(button_text, button_text_rect) + + return button_rect, button_rect_2, button_rect_3, button_rect_4, button_rect_5, button_rect_6 + -def tutorial(): +def templenews(): + # load image used in tutorial + checkers_icon = pygame.image.load('pics/checkersguy_icon.png') + temple_screen = pygame.display.set_mode([Width, Height]) + temple_screen.fill((128, 128, 128)) + + # get latest from r/Temple + client = redditwarp.SYNC.Client() + m = next(client.p.subreddit.pull.top('Temple', amount=1, time='month')) + # print(m.title) + # print(m.permalink) + reddit_text = m.permalink; + + # temple_font = pygame.font.Font(None, 64) + # temple_text = temple_font.render(m.title, True, (255, 255, 255)) + # temple_rect = temple_text.get_rect(center=(Width // 2, 50)) + # temple_screen.blit(temple_text, temple_rect) + + wraplen = 35 + my_wrap = textwrap.TextWrapper(width=wraplen) + wrap_list = my_wrap.wrap(text=m.title) + x = 50; + # Draw one line at a time further down the screen + for i in wrap_list: + x = x + 50 + temple_font = pygame.font.Font(None, 64) + temple_text = temple_font.render(i, True, (255, 255, 255)) + temple_rect = temple_text.get_rect(center=(Width // 2, 50 + x)) + temple_screen.blit(temple_text, temple_rect) + + wraplen = 70 + my_wrap = textwrap.TextWrapper(width=wraplen) + wrap_list = my_wrap.wrap(text=reddit_text) + # Draw one line at a time further down the screen + for i in wrap_list: + x = x + 50 + temple_font = pygame.font.Font(None, 30) + temple_text = temple_font.render(i, True, (255, 255, 255)) + temple_rect = temple_text.get_rect(center=(Width // 2, 100 + x)) + temple_screen.blit(temple_text, temple_rect) + + # Update All Window and contents + # pygame.display.update() + + # Exit button to return back to menu + exit_button_font = pygame.font.Font(None, 32) + exit_button_text = exit_button_font.render("Exit To Menu", True, (255, 255, 255)) + exit_button_rect = exit_button_text.get_rect(center=(Width // 2, Height - 50)) + pygame.draw.rect(temple_screen, (64, 64, 64), exit_button_rect.inflate(20, 10)) + temple_screen.blit(exit_button_text, exit_button_rect) + + pygame.display.flip() + + while True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + return + elif event.type == pygame.MOUSEBUTTONDOWN: + if exit_button_rect.collidepoint(event.pos): # if exit tutorial button is clicked + return # exit tutorial and return to menu + elif event.type == SONG_END: + music_loop() + + +def tutorial(): """ The tutorial function displays the tutorial screen. It displays the tutorial text and image, and allows the user to exit the tutorial after clicking the exit button. The tutorial informs the user on how to use the application and what features are available to them. """ - + # load image used in tutorial checkers_icon = pygame.image.load('pics/checkersguy_icon.png') tutorial_screen = pygame.display.set_mode([Width, Height]) @@ -292,22 +411,31 @@ def tutorial(): # Second message tutorial_font = pygame.font.Font(None, 32) - tutorial_text = tutorial_font.render("This tutorial should provide you with instructions on how to play and use Checkers+.", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "This tutorial should provide you with instructions on how to play and use Checkers+.", True, (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 105)) tutorial_screen.blit(tutorial_text, tutorial_rect) # First paragraph tutorial_font = pygame.font.Font(None, 25) - tutorial_text = tutorial_font.render("There are many features accessible from the Checkers+ menu. You can start a player versus player game, a player", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "There are many features accessible from the Checkers+ menu. You can start a player versus player game, a player", + True, (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 145)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("versus computer game, and access features like the settings, leaderboard, board customization, and this tutorial!", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "versus computer game, and access features like the settings, leaderboard, board customization, and this tutorial!", + True, (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 170)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("The settings will allow you to turn music on or off. You cannot change this once this game starts.", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "The settings will allow you to turn music on or off. You cannot change this once this game starts.", True, + (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 195)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("The rankings will show how many points you have as a player, so make sure the name you enter is correct!", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "The rankings will show how many points you have as a player, so make sure the name you enter is correct!", + True, (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 220)) tutorial_screen.blit(tutorial_text, tutorial_rect) @@ -316,42 +444,64 @@ def tutorial(): button_height = 50 spacing = 10 checkers_icon_resized = pygame.transform.scale(checkers_icon, icon_size) - checkers_icon_rect = checkers_icon_resized.get_rect(topleft=(Width // 2 - 150 + 95, Height // 3+30 + (button_height - icon_size[1]) // 2)) - screen.blit(checkers_icon_resized, checkers_icon_rect.topleft) + checkers_icon_rect = checkers_icon_resized.get_rect( + topleft=(Width // 2 - 150 + 95, Height // 3 + 30 + (button_height - icon_size[1]) // 2)) + screen.blit(checkers_icon_resized, checkers_icon_rect.topleft) # Second paragraph - tutorial_text = tutorial_font.render("To play Checkers+, standard checkers rules are applied...with a twist!", True, (255, 255, 255)) + tutorial_text = tutorial_font.render("To play Checkers+, standard checkers rules are applied...with a twist!", True, + (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 365)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("You only have 5 seconds to make a move, so act fast! If you do not make a move within 5 seconds, ", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "You only have 5 seconds to make a move, so act fast! If you do not make a move within 5 seconds, ", True, + (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 390)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("you will lose your turn. Clicking on a piece will display available moves for that piece.", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "you will lose your turn. Clicking on a piece will display available moves for that piece.", True, + (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 415)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("Like standard checkers, once a piece reaches the opposing player's last row, that piece will become a king.", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "Like standard checkers, once a piece reaches the opposing player's last row, that piece will become a king.", + True, (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 440)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("This is indicated by a crown symbol that will display on the piece. Remember, you can move this piece backwards now!", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "This is indicated by a crown symbol that will display on the piece. Remember, you can move this piece backwards now!", + True, (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 465)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("When the game starts, you will be asked to enter the names of the players (or player, if playing against the computer).", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "When the game starts, you will be asked to enter the names of the players (or player, if playing against the computer).", + True, (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 490)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("Doing this will allow your name(s) and score(s) to be updated on your local leaderboard. 50 points for a win, and", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "Doing this will allow your name(s) and score(s) to be updated on your local leaderboard. 50 points for a win, and", + True, (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 515)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("-50 points for a loss. However, your first loss of the day will not affect your score, so don't quit if you're off to a bad start!", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "-50 points for a loss. However, your first loss of the day will not affect your score, so don't quit if you're off to a bad start!", + True, (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 540)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("By now, you should have a basic understanding of what Checkers+ has to offer. Go give it a try!", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "By now, you should have a basic understanding of what Checkers+ has to offer. Go give it a try!", True, + (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 565)) tutorial_screen.blit(tutorial_text, tutorial_rect) # Developer note - tutorial_text = tutorial_font.render("Note - Currently there is no button to exit a checkers game early. If you would like to quit,", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "Note - Currently there is no button to exit a checkers game early. If you would like to quit,", True, + (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 590)) tutorial_screen.blit(tutorial_text, tutorial_rect) - tutorial_text = tutorial_font.render("simply close the window by clicking the X in the top right corner. This should return you to the main menu.", True, (255, 255, 255)) + tutorial_text = tutorial_font.render( + "simply close the window by clicking the X in the top right corner. This should return you to the main menu.", + True, (255, 255, 255)) tutorial_rect = tutorial_text.get_rect(center=(Width // 2, 615)) tutorial_screen.blit(tutorial_text, tutorial_rect) @@ -374,7 +524,8 @@ def tutorial(): return # exit tutorial and return to menu elif event.type == SONG_END: music_loop() - + + def settings(): """ The settings function displays the settings screen. It displays the music button that allows the user to stop and play the music. It allows the user to exit @@ -392,9 +543,9 @@ def settings(): settings_screen.blit(credits_text1, credits_rect1) settings_screen.blit(credits_text2, credits_rect2) - color = (128, 128, 128) # grey - cursor_color = (100, 100, 100) # darker grey - position = (Width // 2-150, Height // 3-25) + color = (128, 128, 128) # grey + cursor_color = (100, 100, 100) # darker grey + position = (Width // 2 - 150, Height // 3 - 25) size = (300, 50) # width, height button_font = pygame.font.Font(None, 32) @@ -403,10 +554,12 @@ def settings(): position = (Width // 2 - 150, Height // 3 + button_height + spacing) size = (300, button_height) # width, height button_text = button_font.render("Music (On/Off)", True, (255, 255, 255)) # Button text and color - button_text_rect = button_text.get_rect(center=(Width // 2, Height // 3 + button_height + spacing + button_height // 2)) + button_text_rect = button_text.get_rect( + center=(Width // 2, Height // 3 + button_height + spacing + button_height // 2)) # Draw the icon next to the text with the specified size music_icon_resized = pygame.transform.scale(music_icon, icon_size) - music_icon_rect = music_icon_resized.get_rect(topleft=(Width // 2 - 150 + 10, Height // 3 + button_height + spacing + (button_height - icon_size[1]) // 2)) + music_icon_rect = music_icon_resized.get_rect( + topleft=(Width // 2 - 150 + 10, Height // 3 + button_height + spacing + (button_height - icon_size[1]) // 2)) # Create button on screen using position and size parameters pygame.draw.rect(settings_screen, color, pygame.Rect(position, size)) settings_screen.blit(music_icon_resized, music_icon_rect.topleft) # Draw the icon after drawing the button @@ -440,6 +593,7 @@ def settings(): elif event.type == SONG_END and music_playing == True: music_loop() + def show_leaderboard(): """ The show leaderboard function displays the leaderboard screen. It displays the top ten players and their scores. It allows the user to exit the leaderboard after clicking the @@ -452,7 +606,7 @@ def show_leaderboard(): header_text = header_font.render("Leaderboard", True, (255, 255, 255)) header_rect = header_text.get_rect(center=(500, 40)) leaderboard_screen.blit(header_text, header_rect) - + score_manager = ScoreManager("user_data/user_data.json") # Load scores from the JSON file score_manager.load_scores() @@ -472,7 +626,7 @@ def show_leaderboard(): leaderboard_text_rect = leaderboard_text.get_rect(center=(200, leaderboard_y + i * 30)) leaderboard_text_rect.center = (500, leaderboard_y + i * 30) # Adjust the horizontal position as needed leaderboard_screen.blit(leaderboard_text, leaderboard_text_rect) - + pygame.display.flip() # Exit button to return back to menu @@ -495,7 +649,8 @@ def show_leaderboard(): elif event.type == SONG_END: music_loop() -def board_customization(): + +def board_customization(): """ The board customization function displays the board customization screen. It allows the user to change the color of the board to red, blue, yellow, or green. It allows the user to exit the board customization after clicking the exit button. @@ -519,7 +674,7 @@ def board_customization(): # Board Color Text board_color_font = pygame.font.Font(None, 32) board_color_text = board_color_font.render("Board Color", True, (255, 255, 255)) - text_rect = board_color_text.get_rect(center=(Width // 2 - 200, Height // 3 + 80)) + text_rect = board_color_text.get_rect(center=(Width // 2 - 200, Height // 3 + 10)) # Enlarge the box behind the text box_width = text_rect.width + 40 # Increase width box_height = text_rect.height + 20 # Increase height @@ -527,16 +682,89 @@ def board_customization(): # Draw the enlarged box behind the text pygame.draw.rect(board_customization_screen, (128, 128, 128), box_rect) board_customization_screen.blit(board_color_text, text_rect) - - square_side = 50 # Size of the square - red_square_rect = pygame.Rect(text_rect.right + 50, text_rect.centery - square_side // 2, square_side, square_side) - pygame.draw.rect(board_customization_screen, RED, red_square_rect) # Red square - blue_square_rect = pygame.Rect(red_square_rect.right + 20, red_square_rect.top, square_side, square_side) - pygame.draw.rect(board_customization_screen, BLUE, blue_square_rect) # Blue square - yellow_square_rect = pygame.Rect(blue_square_rect.right + 20, blue_square_rect.top, square_side, square_side) - pygame.draw.rect(board_customization_screen, YELLOW, yellow_square_rect) # Yellow square - green_square_rect = pygame.Rect(yellow_square_rect.right + 20, yellow_square_rect.top, square_side, square_side) - pygame.draw.rect(board_customization_screen, GREEN, green_square_rect) # Green square + + # Board Color Rectangles + board_square_side = 50 # Size of the square + board_red_square_rect = pygame.Rect(text_rect.right + 50, text_rect.centery - board_square_side // 2, + board_square_side, board_square_side) + pygame.draw.rect(board_customization_screen, RED, board_red_square_rect) # Red square + board_blue_square_rect = pygame.Rect(board_red_square_rect.right + 20, board_red_square_rect.top, board_square_side, + board_square_side) + pygame.draw.rect(board_customization_screen, BLUE, board_blue_square_rect) # Blue square + board_yellow_square_rect = pygame.Rect(board_blue_square_rect.right + 20, board_blue_square_rect.top, + board_square_side, board_square_side) + pygame.draw.rect(board_customization_screen, YELLOW, board_yellow_square_rect) # Yellow square + board_green_square_rect = pygame.Rect(board_yellow_square_rect.right + 20, board_yellow_square_rect.top, + board_square_side, board_square_side) + pygame.draw.rect(board_customization_screen, GREEN, board_green_square_rect) # Green square + + # Player One Checker Color Text + user_checker_font = pygame.font.Font(None, 32) + user_checker_text = user_checker_font.render("Player One Checker Color", True, (255, 255, 255)) + user_checker_rect = user_checker_text.get_rect(center=(Width // 2 - 240, Height // 3 + 80)) + # Enlarge the box behind the text + user_checker_box_width = user_checker_rect.width + 40 # Increase width + user_checker_box_height = user_checker_rect.height + 20 # Increase height + user_checker_box_rect = pygame.Rect(user_checker_rect.left - 20, user_checker_rect.top - 10, user_checker_box_width, + user_checker_box_height) + # Draw the enlarged box behind the text + pygame.draw.rect(board_customization_screen, (128, 128, 128), user_checker_box_rect) + board_customization_screen.blit(user_checker_text, user_checker_rect) + + # Player One Checker Color Rectangles + user_square_side = 50 # Size of the square + user_black_square_rect = pygame.Rect(user_checker_rect.right + 50, user_checker_rect.top, user_square_side, + user_square_side) + pygame.draw.rect(board_customization_screen, GREY, user_black_square_rect) # Black square + user_white_square_rect = pygame.Rect(user_black_square_rect.right + 20, user_black_square_rect.top, + user_square_side, user_square_side) + pygame.draw.rect(board_customization_screen, WHITE, user_white_square_rect) # White square + user_red_square_rect = pygame.Rect(user_white_square_rect.right + 20, user_white_square_rect.centery - + user_square_side // 2, user_square_side, user_square_side) + pygame.draw.rect(board_customization_screen, RED, user_red_square_rect) # Red square + user_blue_square_rect = pygame.Rect(user_red_square_rect.right + 20, user_red_square_rect.top, user_square_side, + user_square_side) + pygame.draw.rect(board_customization_screen, BLUE, user_blue_square_rect) # Blue square + user_yellow_square_rect = pygame.Rect(user_blue_square_rect.right + 20, user_blue_square_rect.top, user_square_side, + user_square_side) + pygame.draw.rect(board_customization_screen, YELLOW, user_yellow_square_rect) # Yellow square + user_green_square_rect = pygame.Rect(user_yellow_square_rect.right + 20, user_yellow_square_rect.top, + user_square_side, user_square_side) + pygame.draw.rect(board_customization_screen, GREEN, user_green_square_rect) # Green square + + # Player Two Checker Color Text + user_two_checker_font = pygame.font.Font(None, 32) + user_two_checker_text = user_two_checker_font.render("Player Two Checker Color", True, (255, 255, 255)) + user_two_checker_rect = user_two_checker_text.get_rect(center=(Width // 2 - 240, Height // 3 + 150)) + # Enlarge the box behind the text + user_two_checker_box_width = user_two_checker_rect.width + 40 # Increase width + user_two_checker_box_height = user_two_checker_rect.height + 20 # Increase height + user_two_checker_box_rect = pygame.Rect(user_two_checker_rect.left - 20, user_two_checker_rect.top - 10, + user_two_checker_box_width, user_two_checker_box_height) + # Draw the enlarged box behind the text + pygame.draw.rect(board_customization_screen, (128, 128, 128), user_two_checker_box_rect) + board_customization_screen.blit(user_two_checker_text, user_two_checker_rect) + + # Player Two Checker Color Rectangles + user_two_square_side = 50 # Size of the square + user_two_black_square_rect = pygame.Rect(user_two_checker_rect.right + 50, user_two_checker_rect.top, + user_two_square_side, user_two_square_side) + pygame.draw.rect(board_customization_screen, GREY, user_two_black_square_rect) # Black square + user_two_white_square_rect = pygame.Rect(user_two_black_square_rect.right + 20, user_two_black_square_rect.top, + user_two_square_side, user_two_square_side) + pygame.draw.rect(board_customization_screen, WHITE, user_two_white_square_rect) # White square + user_two_red_square_rect = pygame.Rect(user_two_white_square_rect.right + 20, user_two_white_square_rect.centery - + user_two_square_side // 2, user_two_square_side, user_two_square_side) + pygame.draw.rect(board_customization_screen, RED, user_two_red_square_rect) # Red square + user_two_blue_square_rect = pygame.Rect(user_two_red_square_rect.right + 20, user_two_red_square_rect.top, + user_two_square_side, user_two_square_side) + pygame.draw.rect(board_customization_screen, BLUE, user_two_blue_square_rect) # Blue square + user_two_yellow_square_rect = pygame.Rect(user_two_blue_square_rect.right + 20, user_two_blue_square_rect.top, + user_two_square_side, user_two_square_side) + pygame.draw.rect(board_customization_screen, YELLOW, user_two_yellow_square_rect) # Yellow square + user_two_green_square_rect = pygame.Rect(user_two_yellow_square_rect.right + 20, user_two_yellow_square_rect.top, + user_two_square_side, user_two_square_side) + pygame.draw.rect(board_customization_screen, GREEN, user_two_green_square_rect) # Green square pygame.display.flip() @@ -548,15 +776,40 @@ def board_customization(): elif event.type == pygame.MOUSEBUTTONDOWN: if exit_button_rect.collidepoint(event.pos): # if exit settings button is clicked return - if red_square_rect.collidepoint(event.pos): # make board red + if board_red_square_rect.collidepoint(event.pos): # make board red second_menu_instance.color = RED - if blue_square_rect.collidepoint(event.pos): # make board blue + if board_blue_square_rect.collidepoint(event.pos): # make board blue second_menu_instance.color = BLUE - if yellow_square_rect.collidepoint(event.pos): # make board yellow + if board_yellow_square_rect.collidepoint(event.pos): # make board yellow second_menu_instance.color = YELLOW - if green_square_rect.collidepoint(event.pos): # make board green + if board_green_square_rect.collidepoint(event.pos): # make board green second_menu_instance.color = GREEN + if user_black_square_rect.collidepoint(event.pos): # make player one black + second_menu_instance.user_color = BLACK + if user_white_square_rect.collidepoint(event.pos): # make player one white + second_menu_instance.user_color = WHITE + if user_red_square_rect.collidepoint(event.pos): # make player one red + second_menu_instance.user_color = RED + if user_blue_square_rect.collidepoint(event.pos): # make player one blue + second_menu_instance.user_color = BLUE + if user_yellow_square_rect.collidepoint(event.pos): # make player one yellow + second_menu_instance.user_color = YELLOW + if user_green_square_rect.collidepoint(event.pos): # make player one green + second_menu_instance.user_color = GREEN + if user_two_black_square_rect.collidepoint(event.pos): # make player two black + second_menu_instance.user_two_color = BLACK + if user_two_white_square_rect.collidepoint(event.pos): # make player two white + second_menu_instance.user_two_color = WHITE + if user_two_red_square_rect.collidepoint(event.pos): # make player two red + second_menu_instance.user_two_color = RED + if user_two_blue_square_rect.collidepoint(event.pos): # make player two blue + second_menu_instance.user_two_color = BLUE + if user_two_yellow_square_rect.collidepoint(event.pos): # make player two yellow + second_menu_instance.user_two_color = YELLOW + if user_two_green_square_rect.collidepoint(event.pos): # make player two green + second_menu_instance.user_two_color = GREEN elif event.type == SONG_END: music_loop() -main() \ No newline at end of file + +main() diff --git a/pics/Temple.png b/pics/Temple.png new file mode 100644 index 0000000..5d98674 Binary files /dev/null and b/pics/Temple.png differ diff --git a/tempCodeRunnerFile.py b/tempCodeRunnerFile.py new file mode 100644 index 0000000..6d11514 --- /dev/null +++ b/tempCodeRunnerFile.py @@ -0,0 +1,2 @@ +from redditwarp.models.submission_SYNC import Submission as Submission_IO +# from redditwarp.models.submission import Submission \ No newline at end of file diff --git a/user_data/user_data.json b/user_data/user_data.json index 225923e..a0ef174 100644 --- a/user_data/user_data.json +++ b/user_data/user_data.json @@ -1 +1 @@ -{"Nate": 100, "Checkers Master": 250, "Pey": 150} \ No newline at end of file +{"Nate": 100, "Checkers Master": 250, "Pey": 150, "ry": 50, "ryan": 0, "matt": 200, "matt2": 50} \ No newline at end of file