Exemplo n.º 1
0
 def __init__(self):
     Scene.__init__(self)
     self.BACKGROUND_COLOR = (50, 50, 100, 255)
     Button.DEFAULT_BG_COLOR = (100, 100, 100, 255)
     Button.DEFAULT_FONT = "default18"
     Option.DEFAULT_FONT = "default18"
     heistboysLabel = Label(
         (10, 10),
         "Heistboys V 1.0",
     )
     self.labels.add(heistboysLabel)
     debugButton = Button(
         (10, heistboysLabel.pos[1] + heistboysLabel.surface.get_size()[1] + 10),
         "Debug",
         func=self.goToDebug,
     )
     self.buttons.add(debugButton)
     self.debugInput = Input(
         (10, debugButton.pos[1] + debugButton.size[1] + 10),
         "basic"
     )
     self.inputs.add(self.debugInput)
     self.buttons.add(
         Button(
             (utils.SCREEN_W / 2, utils.SCREEN_H - 50),
             "Exit",
             x_centered=True,
             y_centered=True,
             func=exit,
         )
     )
Exemplo n.º 2
0
 def __init__(self):
     Scene.__init__(self)
     self.labels.add(
         Label(
             (5, 5),
             "Hello, World!",
         )
     )
     self.inputs.add(
         Input(
             (50, 50),
             "I'm an Input. Edit me, please.",
         )
     )
     self.options.add(
         Option(
             (100, 100),
             ("Option 1", "Option 2"),
         )
     )
     self.buttons.add(
         Button(
             (200, 200),
             ("As a Button, I find this offensive."),
         )
     )
    def __init__(self, profile=None):
        Scene.__init__(self)
        self.passed_profile = profile
        if self.passed_profile is None:
            print("You must specify a profile to display the stats " + "and acheivements of.")
            sys.exit()
        self.BACKGROUND_COLOR = (0, 0, 50, 255)
        Button.DEFAULT_FONT = "default18"
        Label.DEFAULT_FONT = "default18"
        map_width = int(utils.SCREEN_W / _map.Map.TILE_SIZE) + 1
        map_height = int(utils.SCREEN_H / _map.Map.TILE_SIZE) + 1
        map_size = map_width, map_height
        self.m = _map.Map(size=map_size)
        self.buttons.add(Button((10, utils.SCREEN_H - 10), "Back", func=self.go_to_main_menu, invert_y_pos=True))

        attrs = [attr for attr in dir(profile) if not attr.startswith("__")]
        # Get all non-builtin attributes
        attrs = filter(lambda x: not "__call__" in dir(getattr(profile, x)), attrs)
        # Remove all the methods
        attrs = list(attrs)
        # Turn attrs back into a list
        attrs[attrs.index("name")], attrs[0] = attrs[0], attrs[attrs.index("name")]
        # Put profile.name at the front of the list
        attrs[attrs.index("level")], attrs[1] = (attrs[1], attrs[attrs.index("level")])
        # Put profile.level second to the front of the list
        attrs[2:] = sorted(attrs[2:])
        # Sort the rest of the list lexicographically
        for indx, attr in enumerate(attrs):
            if not attr == "date_created":
                value = str(getattr(profile, attr))
            else:
                value = profile.date_created.strftime("%Y-%m-%d")
            string = attr.replace("_", " ").title() + ": " + value
            self.labels.add(Label((10, 10 + indx * 25), string))
Exemplo n.º 4
0
    def __init__(self, profile=None):
        Scene.__init__(self)
        self.passed_profile = profile
        self.BACKGROUND_COLOR = (0, 0, 50, 255)
        Button.DEFAULT_FONT = "default18"
        Label.DEFAULT_FONT = "default24"
        Input.DEFAULT_FONT = "default24"
        Option.DEFAULT_FONT = "default24"
        self.menu_logo = pygame.image.load(
            os.path.join("assets", "menu_logo_soft_shadow.png"))
        map_width = int(utils.SCREEN_W / _map.Map.TILE_SIZE) + 1
        map_height = int(utils.SCREEN_H / _map.Map.TILE_SIZE) + 1
        map_size = map_width, map_height
        self.m = _map.Map(size=map_size)

        profiles = next(os.walk("profiles"))[2]

        self.profile_option = Option(
            (utils.SCREEN_M[0], utils.SCREEN_M[1] + 70),
            profiles,
            x_centered=True,
        )
        self.options.add(self.profile_option)

        def go_to_main_menu():
            utils.set_scene(menu.Menu(
                profile_name=self.profile_option.label.text, load=True
            ))

        self.buttons.add(
            Button(
                (utils.SCREEN_M[0], utils.SCREEN_M[1] + 140),
                "Select Profile",
                x_centered=True,
                func=go_to_main_menu,
            )
        )

        def go_to_profile_creation():
            utils.set_scene(profile_creation.Profile_Creation())

        self.buttons.add(
            Button(
                (utils.SCREEN_M[0], utils.SCREEN_M[1] + 210),
                "Create New Profile",
                x_centered=True,
                func=go_to_profile_creation,
            )
        )

        if self.passed_profile is not None:
            self.buttons.add(
                Button(
                    (10, utils.SCREEN_H - 10),
                    "Back",
                    func=self.go_back,
                    invert_y_pos=True,
                )
            )
Exemplo n.º 5
0
    def __init__(self):
        Scene.__init__(self)

        self.BACKGROUND_COLOR = (0, 0, 0, 255)

        self.slider1 = Slider(
            (50, utils.SCREEN_H // 2 - Slider.HEIGHT),
            (pygame.K_w, pygame.K_s),
        )
        self.slider2 = Slider(
            (utils.SCREEN_W - Slider.WIDTH - 50, utils.SCREEN_H // 2 - Slider.HEIGHT),
            (pygame.K_UP, pygame.K_DOWN),
        )
        self.square  = Square(
            (utils.SCREEN_W // 2 - Square.WIDTH // 2, utils.SCREEN_H // 2 - Square.HEIGHT // 2),
        )
Exemplo n.º 6
0
 def __init__(self):
     Scene.__init__(self)
     self.labels.add(
         Label(
             (5, 5),
             "Mganga Version 0.0.1",
         )
     )
     self.buttons.add(
         Button(
             utils.SCREEN_M,
             "New World",
             x_centered=True,
             y_centered=True,
         )
     )
Exemplo n.º 7
0
    def __init__(self):
        Scene.__init__(self)
        self.BACKGROUND_COLOR = (0, 0, 50, 255)
        Button.DEFAULT_FONT = "default18"
        Label.DEFAULT_FONT = "default24"
        Input.DEFAULT_FONT = "default24"
        self.menu_logo = pygame.image.load(
            os.path.join("assets", "menu_logo_soft_shadow.png"))
        map_width = int(utils.SCREEN_W / _map.Map.TILE_SIZE) + 1
        map_height = int(utils.SCREEN_H / _map.Map.TILE_SIZE) + 1
        map_size = map_width, map_height
        self.m = _map.Map(size=map_size)
        self.labels.add(
            Label(
                (utils.SCREEN_M[0], utils.SCREEN_M[1] + 70),
                "What is your name?",
                x_centered=True,
            )
        )
        self.profile_name_input = Input(
            (utils.SCREEN_M[0], utils.SCREEN_M[1] + 120),
            "Tom",
            x_centered=True,
        )
        self.inputs.add(self.profile_name_input)

        def go_to_main_menu():
            if self.profile_name_input.label.text:
                if self.profile_name_input.label.text[-1] == "|":
                    profile_name = self.profile_name_input.label.text[:-1]
                else:
                    profile_name = self.profile_name_input.label.text
                utils.set_scene(menu.Menu(profile_name, load=False))

        self.buttons.add(
            Button(
                (utils.SCREEN_M[0], utils.SCREEN_M[1] + 170),
                "Continue",
                x_centered=True,
                func=go_to_main_menu,
            )
        )
Exemplo n.º 8
0
    def __init__(self):
        Scene.__init__(self)

        self.BACKGROUND_COLOR = (0, 0, 0, 255)
        Button.DEFAULT_BG_COLOR = (100, 0, 0, 255)

        self.labels.add(
            Label(
                utils.SCREEN_M,
                "PONG",
                x_centered=True,
                y_centered=True,
                font="default48",
            )
        )

        def go_to_play():
            utils.set_scene( Play() )

        self.buttons.add(
                Button(
                    (utils.SCREEN_W // 2, utils.SCREEN_H // 2 + 100),
                    ("Play"),
		    x_centered=True,
		    y_centered=True,
                    func=go_to_play,
                )
        )
        self.buttons.add(
            Button(
                (utils.SCREEN_W // 2, utils.SCREEN_H // 2 + 160),
                ("Exit"),
                x_centered=True,
                y_centered=True,
                func=sys.exit,
            )
        )
Exemplo n.º 9
0
    def __init__(self, passed_profile):
        Scene.__init__(self)
        if passed_profile is None:
            print("You must specify a profile to create a new game.")
            raise RuntimeError
        else:
            self.passed_profile = passed_profile
        self.BACKGROUND_COLOR = (0, 0, 50, 255)
        Button.DEFAULT_FONT = "default18"
        Label.DEFAULT_FONT = "default24"
        Option.DEFAULT_FONT = "default24"
        map_width = int(utils.SCREEN_W / _map.Map.TILE_SIZE) + 1
        map_height = int(utils.SCREEN_H / _map.Map.TILE_SIZE) + 1
        map_size = map_width, map_height
        self.m = _map.Map(size=map_size)
        map_size_label = Label(
            (10, 10),
            "Map Size:"
        )
        self.labels.add(map_size_label)
        multiplayer_label = Label(
            (
                10,
                map_size_label.pos[1] + \
                map_size_label.surface.get_rect()[3] + 10
            ),
            "Multiplayer:"
        )
        self.labels.add(multiplayer_label)
        game_speed_label = Label(
            (
                10,
                multiplayer_label.pos[1] + \
                multiplayer_label.surface.get_rect()[3] + 10
            ),
            "Game Speed:"
        )
        self.labels.add(game_speed_label)
        advanced_map_customization_label = Label(
            (
                10,
                game_speed_label.pos[1] + \
                game_speed_label.surface.get_rect()[3] + 35
            ),
            "Advanced Map Customization"
        )
        self.labels.add(advanced_map_customization_label)
        advmc_separator_label = Label(
            (
                10,
                advanced_map_customization_label.pos[1] + 10
            ),
            "_"*(len("Advanced Map Customization") - 0)
        )
        self.labels.add(advmc_separator_label)
        temperature_volatility_label = Label(
            (
                10,
                advmc_separator_label.pos[1] + \
                advmc_separator_label.surface.get_rect()[3] + 10
            ),
            "Temperature Volatility:"
        )
        self.labels.add(temperature_volatility_label)
        humidity_volatility_label = Label(
            (
                10,
                temperature_volatility_label.pos[1] + \
                temperature_volatility_label.surface.get_rect()[3] + 10
            ),
            "Humidity Volatility:"
        )
        self.labels.add(humidity_volatility_label)
        altitude_volatility_label = Label(
            (
                10,
                humidity_volatility_label.pos[1] + \
                humidity_volatility_label.surface.get_rect()[3] + 10
            ),
            "Altitude Volatility:"
        )
        self.labels.add(altitude_volatility_label)
        
        self.map_size_option = Option(
            (
                game_speed_label.pos[0] + \
                game_speed_label.surface.get_rect()[2] + 10,
                map_size_label.pos[1],
            ),
            ("Medium", "Large", "Humongous", "Tiny", "Small"),
        )
        self.options.add(self.map_size_option)
        self.multiplayer_option = Option(
            (
                game_speed_label.pos[0] + \
                game_speed_label.surface.get_rect()[2] + 10,
                multiplayer_label.pos[1],
            ),
            ("False", "True"),
        )
        self.options.add(self.multiplayer_option)
        self.game_speed_option = Option(
            (
                game_speed_label.pos[0] + \
                game_speed_label.surface.get_rect()[2] + 10,
                game_speed_label.pos[1],
            ),
            ("Normal", "Fast", "Ludicrous Speed", "Marathon", "Slow"),
        )
        self.options.add(self.game_speed_option)

        self.temperature_volatility_option = Option(
            (
                temperature_volatility_label.pos[0] + \
                temperature_volatility_label.surface.get_rect()[2] + 10,
                temperature_volatility_label.pos[1],
            ),
            ("Normal", "High", "Ludicrous", "Essentially None", "Some",),
        )
        self.options.add(self.temperature_volatility_option)
        self.humidity_volatility_option = Option(
            (
                temperature_volatility_label.pos[0] + \
                temperature_volatility_label.surface.get_rect()[2] + 10,
                humidity_volatility_label.pos[1],
            ),
            ("Normal", "High", "Ludicrous", "Essentially None", "Some",),
        )
        self.options.add(self.humidity_volatility_option)
        self.altitude_volatility_option = Option(
            (
                temperature_volatility_label.pos[0] + \
                temperature_volatility_label.surface.get_rect()[2] + 10,
                altitude_volatility_label.pos[1],
            ),
            ("Normal", "High", "Ludicrous", "Essentially None", "Some",),
        )
        self.options.add(self.altitude_volatility_option)

        self.buttons.add(
            Button(
                (10, utils.SCREEN_H - 10),
                "Back",
                invert_y_pos=True,
                func=self.go_back_to_main_menu,
            )
        )
        self.buttons.add(
            Button(
                (utils.SCREEN_W - 10, utils.SCREEN_H - 10),
                "Start",
                invert_y_pos=True,
                invert_x_pos=True,
                func=self.go_to_in_game,
            )
        )
Exemplo n.º 10
0
 def __init__(self):
     Scene.__init__(self)
     self.m = Map()
Exemplo n.º 11
0
    def __init__(self, profile_name=None, load=False, profile=None):
        Scene.__init__(self)
        if profile_name is None and profile is None:
            print("ERROR: You must specify a profile to play the game.")
            sys.exit()
        if profile is None:
            self.profile = _profile.Profile(name=profile_name, load_from_file=load)
        else:
            self.profile = profile
        self.profile.save()
        self.BACKGROUND_COLOR = (0, 0, 50, 255)
        Button.DEFAULT_FONT = "default18"
        Label.DEFAULT_FONT = "default48"
        self.menu_logo = pygame.image.load(
            os.path.join("assets", "menu_logo_soft_shadow.png"))
        map_width = int(utils.SCREEN_W / _map.Map.TILE_SIZE) + 1
        map_height = int(utils.SCREEN_H / _map.Map.TILE_SIZE) + 1
        map_size = map_width, map_height
        self.m = _map.Map(size=map_size)

        def go_to_new_game():
            utils.set_scene(new_game.New_Game(self.profile))

        self.buttons.add(
            Button(
                (utils.SCREEN_M[0] - 10, utils.SCREEN_M[1] + 70),
                "New Game",
                invert_x_pos=True,
                func=go_to_new_game,
            )
        )

        def go_to_stats_and_acheivements():
            utils.set_scene(
                stats_and_acheivements.Stats_And_Acheivements(self.profile)
            )

        self.buttons.add(
            Button(
                (utils.SCREEN_M[0], utils.SCREEN_M[1] + 210),
                "Stats and Acheivements",
                x_centered=True,
                func=go_to_stats_and_acheivements,
            )
        )
        self.buttons.add(
            Button(
                (utils.SCREEN_M[0] + 10, utils.SCREEN_M[1] + 70),
                "Load Game",
            )
        )
        self.buttons.add(
            Button(
                (utils.SCREEN_M[0] - 10, utils.SCREEN_M[1] + 140),
                "New Campaign",
                invert_x_pos=True,
            )
        )
        self.buttons.add(
            Button(
                (utils.SCREEN_M[0] + 10, utils.SCREEN_M[1] + 140),
                "Load Campaign",
            )
        )
        
        def go_to_profile_selection():
            utils.set_scene(profile_selection.Profile_Selection(self.profile))

        self.buttons.add(
            Button(
                (utils.SCREEN_M[0], utils.SCREEN_M[1] + 280),
                "Select Profile",
                x_centered=True,
                func=go_to_profile_selection,
            )
        )
        self.buttons.add(
            Button(
                (utils.SCREEN_M[0], utils.SCREEN_M[1] + 350),
                "Settings",
                x_centered=True,
            )
        )
        self.buttons.add(
            Button(
                (utils.SCREEN_M[0], utils.SCREEN_M[1] + 420),
                "Exit",
                x_centered=True,
                func=sys.exit,
            )
        )
Exemplo n.º 12
0
 def __init__(self, levelName="basic.lvl"):
     Scene.__init__(self)
     self.BACKGROUND_COLOR = (0, 0, 0, 255)
     item.loadItems()
     self.level = levels.load(levelName)
     self.camera = camera.Camera(locked=self.level.player)
Exemplo n.º 13
0
 def __init__(self,
              profile=None,
              multiplayer=None,
              map_size=None,
              game_speed=None,
              temperature_volatility=None,
              humidity_volatility=None,
              altitude_volatility=None,):
     Scene.__init__(self)
     self.BACKGROUND_COLOR = (0, 0, 50, 255)
     if profile is None:
         print("You must specify a profile to play this game with.")
         raise RuntimeError
     else:
         self.profile = profile
     if multiplayer is None:
         print("You must specify whether this game is multiplayer.")
         raise RuntimeError
     else:
         if multiplayer == "True":
             self.multiplayer = True
         elif multiplayer == "False":
             self.multiplayer = False
         else:
             print(
                 "{} is not a valid multiplayer state.".format(str(multiplayer)))
             raise RuntimeError
     if map_size is None:
         print("You must specify the map size.")
         raise RuntimeError
     else:
         if map_size == "Tiny":
             self.map_size = (30, 30)
         elif map_size == "Small":
             self.map_size = (75, 75)
         elif map_size == "Medium":
             self.map_size = (100, 100)
         elif map_size == "Large":
             self.map_size = (150, 150)
         elif map_size == "Humongous":
             self.map_size = (200, 200)
         else:
             print("{} is not a valid map size.".format(str(map_size)))
             raise RuntimeError
     if game_speed is None:
         print("You must specify the game speed.")
         raise RuntimeError
     else:
         if game_speed == "Marathon":
             self.game_speed = 1
         elif game_speed == "Slow":
             self.game_speed = 2
         elif game_speed == "Normal":
             self.game_speed = 3
         elif game_speed == "Fast":
             self.game_speed = 5
         elif game_speed == "Ludicrous Speed":
             self.game_speed = 10
         else:
             print("{} is not a valid game speed.".format(str(game_speed)))
             raise RuntimeError
     if temperature_volatility is not None:
         if temperature_volatility == "Essentially None":
             self.temperature_volatility = (1, 0)
         elif temperature_volatility == "Some":
             self.temperature_volatility = (3, 0)
         elif temperature_volatility == "Normal":
             self.temperature_volatility = (5, 0)
         elif temperature_volatility == "High":
             self.temperature_volatility = (7, 1)
         elif temperature_volatility == "Ludicrous":
             self.temperature_volatility = (10, 2)
     else:
         self.temperature_volatility = (None, None)
     if humidity_volatility is not None:
         if humidity_volatility == "Essentially None":
             self.humidity_volatility = (1, 0)
         elif humidity_volatility == "Some":
             self.humidity_volatility = (3, 0)
         elif humidity_volatility == "Normal":
             self.humidity_volatility = (5, 0)
         elif humidity_volatility == "High":
             self.humidity_volatility = (7, 1)
         elif humidity_volatility == "Ludicrous":
             self.humidity_volatility = (10, 2)
     else:
         self.humidity_volatility = (None, None)
     if altitude_volatility is not None:
         if altitude_volatility == "Essentially None":
             self.altitude_volatility = (1, 0)
         elif altitude_volatility == "Some":
             self.altitude_volatility = (3, 0)
         elif altitude_volatility == "Normal":
             self.altitude_volatility = (5, 0)
         elif altitude_volatility == "High":
             self.altitude_volatility = (7, 1)
         elif altitude_volatility == "Ludicrous":
             self.altitude_volatility = (10, 2)
     else:
         self.altitude_volatility = (None, None)
     mdt, odt = self.temperature_volatility
     mdh, odh = self.humidity_volatility
     mda, oda = self.altitude_volatility
     self.m = _map.Map(size=self.map_size,
                       i_temp=None, max_d_temp=mdt, off_d_temp=odt,
                       i_hum=None, max_d_hum=mdh, off_d_hum=odh,
                       i_alt=None, max_d_alt=mda, off_d_alt=oda,
     )
     _Helper.initialize()
     self.escape_menu = EscapeMenu()
     self.trays.add(self.escape_menu)