From 3d7e3d1eba26cc57b31337b0708fce3747f8a988 Mon Sep 17 00:00:00 2001 From: Moisis Date: Wed, 17 May 2023 14:04:38 +0300 Subject: Improved GUI Settings added (Debug , Sound) SoundSystem added (Become sometimes laggy) --- src/MacPan.py | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 src/MacPan.py (limited to 'src/MacPan.py') diff --git a/src/MacPan.py b/src/MacPan.py new file mode 100644 index 0000000..f23b752 --- /dev/null +++ b/src/MacPan.py @@ -0,0 +1,164 @@ +import pygame +import sys + +from GUIbutton import Button, ToggleSwitch +from src.game import Game +import ctypes + +from src.settings import Settings, settings + +# icon on taskbar + +ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('Pacman') + +pygame.init() + +SCREEN = pygame.display.set_mode((1280, 720)) +pygame.display.set_caption("Mac-Pan") + +BG = pygame.image.load("../assets/Background.png") + +icon = pygame.image.load("../assets/icon.png") +pygame.display.set_icon(icon) + +lolsettings = settings +lolsettings.debug = False + + +def get_font(size, number): # Returns Press-Start-2P in the desired size + if number == 1: + return pygame.font.Font("../assets/PressStart2P-Regular.ttf", size) + else: + return pygame.font.Font("../assets/PAC-FONT.TTF", size) + + +# def play(): +# while True: +# PLAY_MOUSE_POS = pygame.mouse.get_pos() +# +# SCREEN.fill("black") +# +# PLAY_TEXT = get_font(45).render("This is the PLAY screen.", True, "White") +# PLAY_RECT = PLAY_TEXT.get_rect(center=(640, 260)) +# SCREEN.blit(PLAY_TEXT, PLAY_RECT) +# +# PLAY_BACK = Button(image=None, pos=(640, 460), +# text_input="BACK", font=get_font(75), base_color="White", hovering_color="Green") +# +# PLAY_BACK.changeColor(PLAY_MOUSE_POS) +# PLAY_BACK.update(SCREEN) +# +# for event in pygame.event.get(): +# if event.type == pygame.QUIT: +# pygame.quit() +# sys.exit() +# if event.type == pygame.MOUSEBUTTONDOWN: +# if PLAY_BACK.checkForInput(PLAY_MOUSE_POS): +# main_menu() +# +# pygame.display.update() + +## Todo options sound options here ?? +def options(): + while True: + OPTIONS_MOUSE_POS = pygame.mouse.get_pos() + + SCREEN.fill("#1e1f22") + + OPTIONS_TEXT = get_font(45, 1).render("OPTIONS SCREEN", True, "white") + OPTIONS_RECT = OPTIONS_TEXT.get_rect(center=(630, 150)) + SCREEN.blit(OPTIONS_TEXT, OPTIONS_RECT) + + OPTIONS_BACK = Button(image=None, pos=(640, 520), + text_input="BACK", font=get_font(75, 1), base_color="white", hovering_color="yellow") + + Debug_Mode = ToggleSwitch(image=pygame.image.load('../assets/Quit Rect.png'), pos=(300, 300), + text_input="Debug Mode", font=get_font(20, 1), base_color="Black", + hovering_color="cyan") + + Sound_Mode = ToggleSwitch(image=pygame.image.load('../assets/Quit Rect.png'), pos=(900, 300), + text_input="Sound ", font=get_font(20, 1), base_color="Black", + hovering_color="cyan") + + # Debug_Mode_RECT = Debug_Mode.get_rect(center=(640, 150)) + # SCREEN.blit(Debug_Mode_RECT,Debug_Mode) + + OPTIONS_BACK.changeColor(OPTIONS_MOUSE_POS) + OPTIONS_BACK.update(SCREEN) + Debug_Mode.changeColor(OPTIONS_MOUSE_POS) + Debug_Mode.update(SCREEN) + Sound_Mode.changeColor(OPTIONS_MOUSE_POS) + Sound_Mode.update(SCREEN) + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + sys.exit() + if event.type == pygame.MOUSEBUTTONDOWN: + if OPTIONS_BACK.checkForInput(OPTIONS_MOUSE_POS): + main_menu() + elif Debug_Mode.checkForInput(OPTIONS_MOUSE_POS): + if lolsettings.debug : + lolsettings.debug = False + Debug_Mode.image = (pygame.image.load('../assets/Quit Rect.png')) + Debug_Mode.update(SCREEN) + options() + + else: + lolsettings.debug = True + Debug_Mode.image = (pygame.image.load('../assets/greenboxz.png')) + Debug_Mode.update(SCREEN) + elif Sound_Mode.checkForInput(OPTIONS_MOUSE_POS): + if lolsettings.sound : + lolsettings.sound=False + else: + lolsettings.sound = True + + + pygame.display.update() + + +def main_menu(): + # Initialize Pygame + pygame.init() + while True: + SCREEN.blit(BG, (0, 0)) + + MENU_MOUSE_POS = pygame.mouse.get_pos() + + MENU_TEXT = get_font(100, 2).render("Mac-Pan", True, "#b68f40") + MENU_RECT = MENU_TEXT.get_rect(center=(640, 100)) + + PLAY_BUTTON = Button(image=pygame.image.load("../assets/Play Rect.png"), pos=(640, 250), + text_input="PLAY", font=get_font(75, 2), base_color="#d7fcd4", hovering_color="White") + OPTIONS_BUTTON = Button(image=pygame.image.load("../assets/Options Rect.png"), pos=(640, 400), + text_input="OPTIONS", font=get_font(75, 2), base_color="#d7fcd4", + hovering_color="White") + QUIT_BUTTON = Button(image=pygame.image.load("../assets/Quit Rect.png"), pos=(640, 550), + text_input="QUIT", font=get_font(75, 2), base_color="#d7fcd4", hovering_color="White") + + SCREEN.blit(MENU_TEXT, MENU_RECT) + + for button in [PLAY_BUTTON, OPTIONS_BUTTON, QUIT_BUTTON]: + button.changeColor(MENU_MOUSE_POS) + button.update(SCREEN) + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + sys.exit() + if event.type == pygame.MOUSEBUTTONDOWN: + if PLAY_BUTTON.checkForInput(MENU_MOUSE_POS): + # play() + game = Game(lolsettings) + game.run() + if OPTIONS_BUTTON.checkForInput(MENU_MOUSE_POS): + options() + if QUIT_BUTTON.checkForInput(MENU_MOUSE_POS): + pygame.quit() + sys.exit() + + pygame.display.update() + + +main_menu() -- cgit v1.2.3 From 55efbb61eb7dfb7b8f1faf5de55b239e270d12e4 Mon Sep 17 00:00:00 2001 From: Moisis Date: Wed, 17 May 2023 17:22:32 +0300 Subject: Added SCORE --- src/MacPan.py | 68 ++++++++++++++++++++++------------------------------------- 1 file changed, 25 insertions(+), 43 deletions(-) (limited to 'src/MacPan.py') diff --git a/src/MacPan.py b/src/MacPan.py index f23b752..d6297c6 100644 --- a/src/MacPan.py +++ b/src/MacPan.py @@ -2,10 +2,10 @@ import pygame import sys from GUIbutton import Button, ToggleSwitch -from src.game import Game +from game import Game import ctypes -from src.settings import Settings, settings +from settings import Settings, settings # icon on taskbar @@ -32,33 +32,6 @@ def get_font(size, number): # Returns Press-Start-2P in the desired size return pygame.font.Font("../assets/PAC-FONT.TTF", size) -# def play(): -# while True: -# PLAY_MOUSE_POS = pygame.mouse.get_pos() -# -# SCREEN.fill("black") -# -# PLAY_TEXT = get_font(45).render("This is the PLAY screen.", True, "White") -# PLAY_RECT = PLAY_TEXT.get_rect(center=(640, 260)) -# SCREEN.blit(PLAY_TEXT, PLAY_RECT) -# -# PLAY_BACK = Button(image=None, pos=(640, 460), -# text_input="BACK", font=get_font(75), base_color="White", hovering_color="Green") -# -# PLAY_BACK.changeColor(PLAY_MOUSE_POS) -# PLAY_BACK.update(SCREEN) -# -# for event in pygame.event.get(): -# if event.type == pygame.QUIT: -# pygame.quit() -# sys.exit() -# if event.type == pygame.MOUSEBUTTONDOWN: -# if PLAY_BACK.checkForInput(PLAY_MOUSE_POS): -# main_menu() -# -# pygame.display.update() - -## Todo options sound options here ?? def options(): while True: OPTIONS_MOUSE_POS = pygame.mouse.get_pos() @@ -73,21 +46,22 @@ def options(): text_input="BACK", font=get_font(75, 1), base_color="white", hovering_color="yellow") Debug_Mode = ToggleSwitch(image=pygame.image.load('../assets/Quit Rect.png'), pos=(300, 300), - text_input="Debug Mode", font=get_font(20, 1), base_color="Black", + text_input="Debug Mode is OFF", font=get_font(20, 1), base_color="Black", hovering_color="cyan") Sound_Mode = ToggleSwitch(image=pygame.image.load('../assets/Quit Rect.png'), pos=(900, 300), text_input="Sound ", font=get_font(20, 1), base_color="Black", hovering_color="cyan") - # Debug_Mode_RECT = Debug_Mode.get_rect(center=(640, 150)) - # SCREEN.blit(Debug_Mode_RECT,Debug_Mode) + # Debug_Mode_RECT = Debug_Mode.text.get_rect(center=(640, 150)) OPTIONS_BACK.changeColor(OPTIONS_MOUSE_POS) OPTIONS_BACK.update(SCREEN) - Debug_Mode.changeColor(OPTIONS_MOUSE_POS) + # Debug_Mode.changetext(OPTIONS_MOUSE_POS) + # Debug_Mode.changeColor(OPTIONS_MOUSE_POS) Debug_Mode.update(SCREEN) - Sound_Mode.changeColor(OPTIONS_MOUSE_POS) + # + # #Sound_Mode.changeColor(OPTIONS_MOUSE_POS) Sound_Mode.update(SCREEN) for event in pygame.event.get(): @@ -97,24 +71,33 @@ def options(): if event.type == pygame.MOUSEBUTTONDOWN: if OPTIONS_BACK.checkForInput(OPTIONS_MOUSE_POS): main_menu() + pygame.display.update() elif Debug_Mode.checkForInput(OPTIONS_MOUSE_POS): - if lolsettings.debug : + if lolsettings.debug: lolsettings.debug = False - Debug_Mode.image = (pygame.image.load('../assets/Quit Rect.png')) + # Debug_Mode.update_image2(pygame.image.load('../assets/Quit Rect.png')) + # pygame.display.update() + Debug_Mode.changetext1() Debug_Mode.update(SCREEN) - options() + print(Debug_Mode.text_input) + print("Debug State :") + print(lolsettings.debug) else: lolsettings.debug = True - Debug_Mode.image = (pygame.image.load('../assets/greenboxz.png')) + Debug_Mode.changetext2() Debug_Mode.update(SCREEN) + pygame.display.update() + print("Debug State :") + print(lolsettings.debug) + elif Sound_Mode.checkForInput(OPTIONS_MOUSE_POS): - if lolsettings.sound : - lolsettings.sound=False + if lolsettings.sound: + lolsettings.sound = False + print(lolsettings.sound) else: lolsettings.sound = True - - + print(lolsettings.sound) pygame.display.update() @@ -149,7 +132,6 @@ def main_menu(): sys.exit() if event.type == pygame.MOUSEBUTTONDOWN: if PLAY_BUTTON.checkForInput(MENU_MOUSE_POS): - # play() game = Game(lolsettings) game.run() if OPTIONS_BUTTON.checkForInput(MENU_MOUSE_POS): -- cgit v1.2.3 From 6a351ed2d6a554ed6d338abba234527705d1040f Mon Sep 17 00:00:00 2001 From: Moisis Date: Fri, 19 May 2023 23:40:23 +0300 Subject: Final Touches #2 --- src/MacPan.py | 50 +++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) (limited to 'src/MacPan.py') diff --git a/src/MacPan.py b/src/MacPan.py index d6297c6..e06e577 100644 --- a/src/MacPan.py +++ b/src/MacPan.py @@ -1,7 +1,7 @@ import pygame import sys -from GUIbutton import Button, ToggleSwitch +from GUIbutton import Button from game import Game import ctypes @@ -45,23 +45,17 @@ def options(): OPTIONS_BACK = Button(image=None, pos=(640, 520), text_input="BACK", font=get_font(75, 1), base_color="white", hovering_color="yellow") - Debug_Mode = ToggleSwitch(image=pygame.image.load('../assets/Quit Rect.png'), pos=(300, 300), - text_input="Debug Mode is OFF", font=get_font(20, 1), base_color="Black", - hovering_color="cyan") + Debug_Mode = Button(image=pygame.image.load('../assets/Quit Rect.png'), pos=(300, 300), + text_input="Debug Mode", font=get_font(20, 1), base_color="Black", + hovering_color="yellow") - Sound_Mode = ToggleSwitch(image=pygame.image.load('../assets/Quit Rect.png'), pos=(900, 300), + Sound_Mode = Button(image=pygame.image.load('../assets/Quit Rect.png'), pos=(900, 300), text_input="Sound ", font=get_font(20, 1), base_color="Black", - hovering_color="cyan") + hovering_color="yellow") - # Debug_Mode_RECT = Debug_Mode.text.get_rect(center=(640, 150)) - - OPTIONS_BACK.changeColor(OPTIONS_MOUSE_POS) + OPTIONS_BACK.changeColor(OPTIONS_MOUSE_POS, 'BACK', 'BACK') OPTIONS_BACK.update(SCREEN) - # Debug_Mode.changetext(OPTIONS_MOUSE_POS) - # Debug_Mode.changeColor(OPTIONS_MOUSE_POS) Debug_Mode.update(SCREEN) - # - # #Sound_Mode.changeColor(OPTIONS_MOUSE_POS) Sound_Mode.update(SCREEN) for event in pygame.event.get(): @@ -75,28 +69,21 @@ def options(): elif Debug_Mode.checkForInput(OPTIONS_MOUSE_POS): if lolsettings.debug: lolsettings.debug = False - # Debug_Mode.update_image2(pygame.image.load('../assets/Quit Rect.png')) - # pygame.display.update() - Debug_Mode.changetext1() - Debug_Mode.update(SCREEN) - print(Debug_Mode.text_input) print("Debug State :") print(lolsettings.debug) - else: lolsettings.debug = True - Debug_Mode.changetext2() - Debug_Mode.update(SCREEN) - pygame.display.update() print("Debug State :") print(lolsettings.debug) elif Sound_Mode.checkForInput(OPTIONS_MOUSE_POS): if lolsettings.sound: lolsettings.sound = False + print("Sound State :") print(lolsettings.sound) else: lolsettings.sound = True + print("Sound State :") print(lolsettings.sound) pygame.display.update() @@ -113,18 +100,23 @@ def main_menu(): MENU_RECT = MENU_TEXT.get_rect(center=(640, 100)) PLAY_BUTTON = Button(image=pygame.image.load("../assets/Play Rect.png"), pos=(640, 250), - text_input="PLAY", font=get_font(75, 2), base_color="#d7fcd4", hovering_color="White") + text_input="PLaY", font=get_font(75, 2), base_color="#d7fcd4", hovering_color="#b68f40") OPTIONS_BUTTON = Button(image=pygame.image.load("../assets/Options Rect.png"), pos=(640, 400), - text_input="OPTIONS", font=get_font(75, 2), base_color="#d7fcd4", - hovering_color="White") + text_input="OPTIoNS", font=get_font(75, 2), base_color="#d7fcd4", + hovering_color="#b68f40") QUIT_BUTTON = Button(image=pygame.image.load("../assets/Quit Rect.png"), pos=(640, 550), - text_input="QUIT", font=get_font(75, 2), base_color="#d7fcd4", hovering_color="White") + text_input="qUIT", font=get_font(75, 2), base_color="#d7fcd4", hovering_color="#b68f40") SCREEN.blit(MENU_TEXT, MENU_RECT) - for button in [PLAY_BUTTON, OPTIONS_BUTTON, QUIT_BUTTON]: - button.changeColor(MENU_MOUSE_POS) - button.update(SCREEN) + PLAY_BUTTON.changeColor(MENU_MOUSE_POS, "PLay", "PLAY") + PLAY_BUTTON.update(SCREEN) + + OPTIONS_BUTTON.changeColor(MENU_MOUSE_POS, "oPTIoNs", "OPTIONS") + OPTIONS_BUTTON.update(SCREEN) + + QUIT_BUTTON.changeColor(MENU_MOUSE_POS, "qUIT", "QUIT") + QUIT_BUTTON.update(SCREEN) for event in pygame.event.get(): if event.type == pygame.QUIT: -- cgit v1.2.3