diff --git a/__pycache__/Main_Board.cpython-311.pyc b/__pycache__/Main_Board.cpython-311.pyc index a4f5bc8..865fbb6 100644 Binary files a/__pycache__/Main_Board.cpython-311.pyc and b/__pycache__/Main_Board.cpython-311.pyc differ diff --git a/__pycache__/Main_Board.cpython-312.pyc b/__pycache__/Main_Board.cpython-312.pyc new file mode 100644 index 0000000..59c3a92 Binary files /dev/null and b/__pycache__/Main_Board.cpython-312.pyc differ diff --git a/__pycache__/MusicClass.cpython-311.pyc b/__pycache__/MusicClass.cpython-311.pyc new file mode 100644 index 0000000..3b617bb 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..bb9ffbb 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..556a008 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..83eec6b 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..69ecc93 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..1f9e36e 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..009ca30 100644 Binary files a/__pycache__/SecondMenu.cpython-311.pyc and b/__pycache__/SecondMenu.cpython-311.pyc differ diff --git a/__pycache__/SecondMenu.cpython-312.pyc b/__pycache__/SecondMenu.cpython-312.pyc new file mode 100644 index 0000000..9317919 Binary files /dev/null and b/__pycache__/SecondMenu.cpython-312.pyc differ diff --git a/__pycache__/SharedObjects.cpython-311.pyc b/__pycache__/SharedObjects.cpython-311.pyc new file mode 100644 index 0000000..811e08b 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..69f89f5 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..4cd23cf 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..6e36442 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..b79f0a8 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..1b62289 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..d00b1c3 100644 Binary files a/__pycache__/game.cpython-311.pyc and b/__pycache__/game.cpython-311.pyc differ diff --git a/__pycache__/game.cpython-312.pyc b/__pycache__/game.cpython-312.pyc new file mode 100644 index 0000000..ed4ede6 Binary files /dev/null and b/__pycache__/game.cpython-312.pyc differ diff --git a/__pycache__/pieces.cpython-311.pyc b/__pycache__/pieces.cpython-311.pyc index 174e8c4..83c758d 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..4f212ba Binary files /dev/null and b/__pycache__/pieces.cpython-312.pyc differ diff --git a/game.py b/game.py index af2a738..a4c2a04 100644 --- a/game.py +++ b/game.py @@ -31,6 +31,7 @@ def __init__(self, win, color, player1, player2): self.screen = pygame.display.set_mode((1000, 700)) self.player1 = player1 self.player2 = player2 + self.history_moves= [] def check_turn_timeout(self): """ @@ -82,6 +83,19 @@ def display_player_names(self, player1, player2): self.screen.blit(text_surface, (715, 350)) self.screen.blit(text_surface2, (715, 400)) + def display_history_moves(self): + """ + The display history moves function displays the last 10 moves on the screen. + """ + text = "Last 10 Players Moves: " + text_surface = self.font.render(text, True, self.text_color) + self.screen.blit(text_surface, (695, 450)) + move_location_starter = 470 + for i in range(min(10, len(self.history_moves))): # Ensure you don't go out of bounds + moves = str(i+1) + ". " + self.history_moves[i] # Add a space after the dot for better formatting + moves_surface = self.font.render(moves, True, self.text_color) + self.screen.blit(moves_surface, (695, move_location_starter + i * 20)) # Adjust y-coordinate + def update(self): """ The update function updates the board to show the current board and features. @@ -92,6 +106,7 @@ def update(self): self.display_turn() self.display_piece_count() self.display_player_names(self.player1, self.player2) + self.display_history_moves() pygame.display.update() def winner(self): @@ -126,11 +141,40 @@ def move(self, row, col): The move function moves a piece to a given row and column and changes the turn. """ piece = self.board.get_piece(row, col) + current_row = self.selected.row+1 + current_column = self.selected.col+1 + current_red_king= self.board.red_kings + current_white_king= self.board.white_kings if self.selected and piece == 0 and (row, col) in self.valid_moves: self.board.move(self.selected, row, col) + if(self.turn == RED): + move = f"Red[{current_column},{9-current_row}] to [{col + 1},{9-(row + 1)}]" + if self.board.red_kings>current_red_king: + self.history_moves.insert(0, move) + move = "Red King" + else: + move = f"White[{current_column},{9-current_row}] to [{col + 1},{9-(row + 1)}]" + if self.board.white_kings>current_white_king: + self.history_moves.insert(0, move) + move = "White King" + skipped = self.valid_moves.get((row, col)) if skipped: self.board.remove(skipped) + if(self.turn == RED): + self.history_moves.insert(0, move) + if(len(skipped)>1): + move = "Red DoubleJump White" + else: + move = "Red jump White" + else: + self.history_moves.insert(0, move) + if(len(skipped)>1): + move = "White DoubleJump Red" + else: + move = "White jump Red" + + self.history_moves.insert(0, move) self.change_turn() self.turn_start_time = pygame.time.get_ticks() # Reset the turn timer return True diff --git a/main.py b/main.py index d7bbf32..94edefc 100644 --- a/main.py +++ b/main.py @@ -4,15 +4,20 @@ """ import pygame +import redditwarp.SYNC from SecondMenu import SecondMenu from constants import BLUE, YELLOW, RED, GREEN from ScoreManager import ScoreManager from SecondMenu import SecondMenu + pygame.init() pygame.mixer.init() # initialize pygame mixer for music +#create client for redditwarp +client = redditwarp.SYNC.Client() + # set up the drawing window Width, Height = 1000, 700 # updated size screen = pygame.display.set_mode([Width, Height]) @@ -81,10 +86,13 @@ def main(): second_menu_instance.start_game_menu() if buttons[2].collidepoint(event.pos): # if mouse is clicked on tutorial button tutorial() + if buttons[5].collidepoint(event.pos): + TempleNews() 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) board_customization() + # Check if the current song has finished, loop to next song elif event.type == SONG_END: music_loop() @@ -116,16 +124,16 @@ 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 // 3 + (button_height - icon_size[1] - 50) // 2 - 75)) color = (128, 128, 128) # grey cursor_color = (100, 100, 100) # darker grey - position = (Width // 2-150, Height // 3-25) + position = (Width // 2-150, Height // 3-25-75) 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_rect = button_text.get_rect(center=(Width // 2, Height // 3-75)) # Create button on screen using position and size parameters pygame.draw.rect(screen, color, pygame.Rect(position, size)) @@ -146,15 +154,15 @@ 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 // 3 + button_height + spacing - 75) 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 // 3 + button_height + spacing + button_height // 2 - 75)) # 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 // 3 + button_height + spacing + (button_height - icon_size[1]) // 2 - 75)) # Create button on screen using position and size parameters pygame.draw.rect(screen, color, pygame.Rect(position, size)) @@ -177,18 +185,18 @@ def menu_buttons(): color = (128, 128, 128) # grey cursor_color = (100, 100, 100) # darker grey - position = (Width // 2-150, Height // 3 + 135) + position = (Width // 2-150, Height // 3 + 135 - 75) 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_rect = button_text.get_rect(center=(Width // 2, Height // 3+160-75)) 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 // 3 + 135 + (button_height - icon_size[1]) // 2-75)) pygame.draw.rect(screen, color, pygame.Rect(position, size)) screen.blit(button_text, button_text_rect) @@ -209,19 +217,19 @@ def menu_buttons(): 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 + position = (Width // 2 - 150, Height // 3 + 210-75) # 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_rect = button_text.get_rect(center=(Width // 2, Height // 3 + 235-75)) # 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 // 3 + 210 + (button_height - icon_size[1]) // 2-75)) pygame.draw.rect(screen, color, pygame.Rect(position, size)) screen.blit(button_text, button_text_rect) @@ -244,18 +252,18 @@ def menu_buttons(): 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 + position = (Width // 2 - 150, Height // 3 + 285-75) # 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_rect = button_text.get_rect(center=(Width // 2, Height // 3 + 310-75)) # 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 // 3 + 285 + (button_height - icon_size[1]) // 2-75)) pygame.draw.rect(screen, color, pygame.Rect(position, size)) screen.blit(button_text, button_text_rect) @@ -270,9 +278,89 @@ def menu_buttons(): screen.blit(board_icon_resized, board_icon_rect.topleft) # Draw the icon after drawing the button screen.blit(button_text, button_text_rect) + + # Temple Twitter News Button + twitter_icon = pygame.image.load('pics/twitter_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 + 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 // 3 + 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 + twitter_icon_resized = pygame.transform.scale(twitter_icon, icon_size) + twitter_icon_rect = twitter_icon_resized.get_rect(topleft=(Width // 2 - 150 + 10, Height // 3 + 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_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(twitter_icon_resized, twitter_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 TempleNews(): + + # load image used in tutorial + News_screen = pygame.display.set_mode([Width, Height]) + News_screen.fill((128, 128, 128)) + + # First message + News_font = pygame.font.Font(None, 64) + News_text = News_font.render("Temple News", True, (255, 255, 255)) + News_rect = News_text.get_rect(center=(Width // 2, 50)) + News_screen.blit(News_text, News_rect) + + # Display posts + posts = client.p.subreddit.pull.hot("Temple", 5) + post_list = list(posts) + Post_Starting_Y = 100 # Starting Y position for the first post, adjusted for better spacing from the title + Posts_font = pygame.font.Font(None, 24) + + # Calculate spacing based on the screen height and number of posts + # This tries to evenly distribute the posts vertically + num_posts = len(post_list) + spacing = (Height - Post_Starting_Y - 100) // num_posts # Adjust the bottom padding as needed + + for subm in post_list: + Posts_text = Posts_font.render("{0.permalink}".format(subm), True, (255, 255, 255)) + # Use Post_Starting_Y for the Y coordinate directly, without subtracting from Height + Posts_rect = Posts_text.get_rect(center=(Width // 2, Post_Starting_Y)) + News_screen.blit(Posts_text, Posts_rect) + Post_Starting_Y += spacing # Increment Y position for the next post - return button_rect, button_rect_2, button_rect_3, button_rect_4, button_rect_5 + # Exit button to return back to menu + exit_button_font = pygame.font.Font(None, 32) + exit_button_text = exit_button_font.render("Exit Temple News", True, (255, 255, 255)) + exit_button_rect = exit_button_text.get_rect(center=(Width // 2, Height - 50)) + pygame.draw.rect(News_screen, (64, 64, 64), exit_button_rect.inflate(20, 10)) + News_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. diff --git a/pics/twitter_icon.png b/pics/twitter_icon.png new file mode 100644 index 0000000..887e575 Binary files /dev/null and b/pics/twitter_icon.png differ