aboutsummaryrefslogtreecommitdiff
path: root/src/MacPan.py
blob: e06e577031b5493adde014ab01bb2a66bbf581a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import pygame
import sys

from GUIbutton import Button
from game import Game
import ctypes

from 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 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 = 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 = 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="yellow")

        OPTIONS_BACK.changeColor(OPTIONS_MOUSE_POS, 'BACK', 'BACK')
        OPTIONS_BACK.update(SCREEN)
        Debug_Mode.update(SCREEN)
        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()
                    pygame.display.update()
                elif Debug_Mode.checkForInput(OPTIONS_MOUSE_POS):
                    if lolsettings.debug:
                        lolsettings.debug = False
                        print("Debug State  :")
                        print(lolsettings.debug)
                    else:
                        lolsettings.debug = True
                        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()


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="#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="#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="#b68f40")

        SCREEN.blit(MENU_TEXT, MENU_RECT)

        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:
                pygame.quit()
                sys.exit()
            if event.type == pygame.MOUSEBUTTONDOWN:
                if PLAY_BUTTON.checkForInput(MENU_MOUSE_POS):
                    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()