diff --git a/ending_screens.py b/ending_screens.py index 232e96c..bae4707 100644 --- a/ending_screens.py +++ b/ending_screens.py @@ -61,12 +61,12 @@ def _createUI(self, kwargs): def scores(self) -> bool: snd_win = pg.mixer.Sound("data/sounds/win_effect.mp3") pg.mixer.Sound.play(snd_win) - pg.mixer.Sound.set_volume(snd_win, 0.1) + pg.mixer.Sound.set_volume(snd_win, 0.25) pg.time.wait(1000) snd = pg.mixer.Sound("data/soundtracks/score.mp3") pg.mixer.Sound.play(snd, -1) - pg.mixer.Sound.set_volume(snd, 0.05) + pg.mixer.Sound.set_volume(snd, 0.25) pg.mouse.set_visible(True) @@ -198,7 +198,7 @@ def _show_lb(self): def run(self): snd = pg.mixer.Sound(f"data/soundtracks/leaderboard.mp3") pg.mixer.Sound.play(snd, -1) - pg.mixer.Sound.set_volume(snd, 0.05) + pg.mixer.Sound.set_volume(snd, 0.35) is_running = True clock = pg.time.Clock() diff --git a/main.py b/main.py index 486bfa8..0b9169b 100644 --- a/main.py +++ b/main.py @@ -39,6 +39,9 @@ def game_run(): play_again = False name1, name2 = None, None + + score1, score2 = 0, 0 + while isRunning: pg.mouse.set_visible(False) @@ -77,7 +80,9 @@ def game_run(): pg.mouse.set_visible(False) MainScreen_object = MainScreen(screen, is_controller) - play_again = MainScreen_object.main_screen(usernames=[name1, name2]) + play_again = MainScreen_object.main_screen( + score1, score2, usernames=[name1, name2] + ) def re_exec(): diff --git a/main_screen.py b/main_screen.py index 7932aa9..14a7812 100644 --- a/main_screen.py +++ b/main_screen.py @@ -29,7 +29,7 @@ def __init__( self.chip_2 = self.config.chip_2 self.ai_chip = 2 - def main_screen(self, usernames: list, option="AI"): + def main_screen(self, score1: int, score2: int, usernames: list, option="AI"): control = Controller() utilities = UtilitiesMain(self.screen) @@ -64,6 +64,7 @@ def main_screen(self, usernames: list, option="AI"): pg.mixer.music.play(loops=-1) pg.mixer.music.set_volume(self.volume) + while not close_loop: start_time = utilities.draw_board(matrix, start_time, clock, usernames) @@ -83,14 +84,20 @@ def main_screen(self, usernames: list, option="AI"): x = event.pos[0] y = event.pos[1] - print(x, y) + # print(x, y) if event.type == pg.MOUSEBUTTONDOWN: save_chip = chip column = utilities.location_X(pg.mouse.get_pos()[0]) if column != 0: - play_again, player_turn, chip = utilities.playersTurn( + ( + play_again, + player_turn, + chip, + score1, + score2, + ) = utilities.playersTurn( column, matrix, player_turn, @@ -99,6 +106,8 @@ def main_screen(self, usernames: list, option="AI"): usernames, start_time, clock, + score1, + score2, option, ) @@ -114,7 +123,13 @@ def main_screen(self, usernames: list, option="AI"): column = utilities.location_X(control.get_x_pos(event)) if column != 0: - play_again, player_turn, chip = utilities.playersTurn( + ( + play_again, + player_turn, + chip, + score1, + score2, + ) = utilities.playersTurn( column, matrix, player_turn, @@ -123,6 +138,8 @@ def main_screen(self, usernames: list, option="AI"): usernames, start_time, clock, + score1, + score2, option, ) @@ -152,11 +169,20 @@ def main_screen(self, usernames: list, option="AI"): utilities.drop_piece(matrix, row, column, self.ai_chip) if utilities.is_victory(matrix, self.ai_chip): - utilities.draw_board(matrix, start_time, clock, usernames) + print(score2, player_turn) + print(score1, player_turn) + score2 += 1 + print(score2, player_turn) + + start_time = utilities.draw_board( + matrix, start_time, clock, usernames + ) + + pg.display.update() - pg.time.wait(500) + pg.time.wait(1500) - data = {usernames[0]: 10, usernames[1]: 5} + data = {usernames[0]: score1, usernames[1]: score2} ending = EndingScreen( self.screen, diff --git a/utilities.py b/utilities.py index 2447db4..a065418 100644 --- a/utilities.py +++ b/utilities.py @@ -252,6 +252,8 @@ def playersTurn( usernames, start_time, clock, + score1, + score2, option="AI", ): turn = player_turn @@ -271,12 +273,20 @@ def playersTurn( self.drop_piece(matrix, row, column, turn) if self.is_victory(matrix, turn) or self.is_tie(matrix): + print(score1, turn) + print(score2, turn) + score1 += 1 if turn % 2 == 0 else score1 + print(score1, turn) + score2 += 1 if turn % 2 == 1 else score2 + print(score2, turn) - self.draw_board(matrix, start_time, clock, usernames) + start_time = self.draw_board(matrix, start_time, clock, usernames) - pg.time.wait(500) + pg.display.update() - data = {usernames[0]: 10, usernames[1]: 5} + pg.time.wait(1500) + + data = {usernames[0]: score1, usernames[1]: score2} ending = EndingScreen( self.screen, @@ -290,7 +300,7 @@ def playersTurn( play_again = ending.scores() - return play_again, turn, chip + return play_again, turn, chip, score1, score2 def evaluate_window(self, window, chip): score = 0