예제 #1
0
    def load_options(self):
        """
        Loads all options from the settings file.
        """
        with open(os.path.join("Menus", "settings"), "r") as file:
            for line in file.read().splitlines():
                option_name, different_options = line.split(":")
                different_options, selected_option = different_options.split(
                    " | ")
                different_options = different_options.split(" ")
                selected_option = selected_option.replace(" ", "")
                self.options[option_name] = [
                    TextButton(self.position[:], option_name + ": ",
                               FONT_MEDIUM, pygame.Color("white")),
                ]
                SettingsMenu.SETTINGS[option_name] = selected_option
                current_pos = self.position[:]
                for option in different_options:
                    current_pos[
                        0] += 10 + self.options[option_name][-1].size[0]
                    self.options[option_name].append(
                        TextButton(current_pos[:], option, FONT_MEDIUM,
                                   pygame.Color("white"), pygame.Color("red")))
                    if option == selected_option:
                        self.options[option_name][-1].selected = True

                self.position[1] += self.options[option_name][0].size[1] + 10
예제 #2
0
    def __init__(self, screen):
        self.screen = screen
        self.phrases = [
            "This game was made by Jasper Dekoninck.",
            "You can use the code for whatever you want, no permission is required.",
            "Most sprites are copied from http://www.mariouniverse.com/sprites-ds-nsmb/.",
            "",
            "A small guide for the creation of new levels is probably required.",
            "If you click on 'Level Creator' in main menu, you will be able to create new worlds yourself.",
            "Just follow the steps, when you're doing the actual creating, you can do the following things:",
            "1. Select a game object at the right side by pressing your left mouse button on it.",
            "     Once selected, you can place the game object in your world by again pressing the left mouse button.",
            "     You can create multiple instances of the same object by keeping the mouse pressed.",
            "2. You can delete game objects by clicking on them with your right mouse button.",
            "3. You can move the screen up / down / left / right by using the arrow keys.",
            "4. You can play your world in creation by pressing the escape key.",
            "     If you press the key again, you stop playing.",
            "You can save your world by pressing enter."
        ]
        self.buttons = []
        y_pos = 10
        for phrase in self.phrases:
            self.buttons.append(TextButton((10, y_pos), phrase, FONT_STANDARD, pygame.Color("white")))
            y_pos += self.buttons[-1].size[1] + 2

        pos_main = (10, y_pos + self.buttons[-1].size[1] + 10)
        self.main_button = TextButton(pos_main, "Main menu", FONT_BIG, pygame.Color("white"), pygame.Color("red"))

        # A variable registering how long the user has been in the menu. Not allowing anything to happen before
        # this variable gets to a certain size, makes sure it is not possible to accidently click and go two menus
        # further
        self.time_after_creation = 0
        self.clock = pygame.time.Clock()
예제 #3
0
    def __init__(self, screen):
        self.screen = screen
        self.report_button = TextButton((10, 10), "You won!", FONT_BIG,
                                        pygame.Color("White"))
        self.play_button = TextButton((10, 70), "Play again", FONT_BIG,
                                      pygame.Color("white"),
                                      pygame.Color("red"))
        self.main_button = TextButton((10, 130), "Main menu", FONT_BIG,
                                      pygame.Color("white"),
                                      pygame.Color("red"))
        self.clock = pygame.time.Clock()

        # A variable registering how long the user has been in the menu. Not allowing anything to happen before
        # this variable gets to a certain size, makes sure it is not possible to accidently click and go two menus
        # further
        self.time_after_creation = 0
예제 #4
0
    def __init__(self, screen):
        self.screen = screen
        self.settings_button = TextButton((10, 10), "Settings", FONT_BIG,
                                          pygame.Color("White"))
        self.options = dict()
        self.position = [10, 70]
        self.load_options()
        self.main_button = TextButton(self.position, "Main menu", FONT_BIG,
                                      pygame.Color("white"),
                                      pygame.Color("red"))
        self.clock = pygame.time.Clock()

        # A variable registering how long the user has been in the menu. Not allowing anything to happen before
        # this variable gets to a certain size, makes sure it is not possible to accidently click and go two menus
        # further
        self.time_after_creation = 0
예제 #5
0
 def __init__(self, screen):
     self.screen = screen
     # Loading the background world for the main menu
     self.background_world = World(
         load_file=os.path.join("Worlds", "MarioBros"))
     self.play_button = TextButton((10, 10), "Play game", FONT_BIG,
                                   pygame.Color("white"),
                                   pygame.Color("red"))
     self.level_button = TextButton((10, 60), "Level Creator", FONT_BIG,
                                    pygame.Color("white"),
                                    pygame.Color("red"))
     self.about_button = TextButton((10, 110), "About", FONT_BIG,
                                    pygame.Color("white"),
                                    pygame.Color("red"))
     self.settings_button = TextButton((10, 160), "Settings", FONT_BIG,
                                       pygame.Color("white"),
                                       pygame.Color("red"))
     self.clock = pygame.time.Clock()
     self.time_since_creation = 0
예제 #6
0
 def check_levels(self):
     """
     Loads all levels and creates buttons for each one of them.
     """
     self.buttons = []
     x_pos = 10
     y_pos = 10
     for i, file in enumerate(os.listdir("Worlds")):
         pos = (x_pos, y_pos)
         self.buttons.append(TextButton(pos, file, FONT_SMALL, pygame.Color("white"), pygame.Color("red")))
         x_pos += self.buttons[-1].size[0] + 10
         if x_pos + self.buttons[-1].size[0] > SCREEN_SIZE[0]:
             x_pos = 10
             y_pos = y_pos + self.buttons[-1].size[1] + 10