def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.cursor_pos = 0
        self.desc_widget = wgt.Text(
            renderer=self.game.renderer,
            size=constants.MENU_SCALE * 10,
            offset=(self.game.width/4, self.game.height/2 + constants.MENU_SCALE * 45)
        )
        self.detail_widget = wgt.TextLines(
            renderer=self.game.renderer,
            size=constants.MENU_SCALE * 5,
            offset=(self.game.width/4, self.game.height/2 + constants.MENU_SCALE * 60)
        )

        self.widgets = [
            wgt.Text(
                renderer=self.game.renderer,
                text="Choose your character",
                size=constants.MENU_SCALE * 15,
                offset=(self.game.width / 2, constants.MENU_SCALE * 100),
                centered=True
            ),
            self.desc_widget,
            self.detail_widget
        ]
Exemple #2
0
    def __init__(self, dungeon, victory, **kwargs):
        super().__init__(**kwargs)
        self.victory = victory
        self.dungeon = dungeon
        self.width = self.REL_WIDTH * constants.MENU_SCALE
        self.height = self.REL_HEIGHT * constants.MENU_SCALE
        self.x = (self.game.width - self.width) / 2
        self.y = (self.game.height - self.height) / 2

        text_x = self.x + 5 * constants.MENU_SCALE
        text_y = self.y + 5 * constants.MENU_SCALE
        if victory:
            top_text = self._get_win_text()
        else:
            top_text = self._get_lose_text()
        self.text = wgt.TextLines(
            renderer=self.game.renderer,
            color=constants.WHITE,
            size=5 * constants.MENU_SCALE,
            offset=(text_x, text_y),
            text=(*top_text, "Time: " + time_to_str(dungeon.game_time),
                  "You killed " + pluralise(dungeon.kills, "creature") + ".",
                  " ", "Space to continue playing" if self.victory else
                  "Space to play again", "Escape to finish run"
                  if self.victory else "Space to return to the Main Menu"))
Exemple #3
0
    def _start_main_menu(self):
        """Add everything to the main menu. Called after the title drops.

        The main menu animation and proper main menu could be two seperate scenes.
        """
        audio.play_music(constants.MUSIC_DUNGEON)
        options = ["New game", "Settings", "Exit"]
        if self.game.has_save():
            options.insert(0, "Continue game")
        pos = (self.game.width // 2, self.game.height // 2)
        option_select = self.add_child_scene(OptionSelect, options, pos)
        self.game.set_focus(option_select)
        option_select.connect_signal("selected", self.selected_option)

        # Help text
        self.widgets = (wgt.Text(renderer=self.game.renderer,
                                 offset=(5 * constants.MENU_SCALE,
                                         5 * constants.MENU_SCALE),
                                 size=5 * constants.MENU_SCALE,
                                 color=constants.LIGHT_GRAY,
                                 text="CONTROLS"),
                        wgt.TextLines(
                            renderer=self.game.renderer,
                            offset=(5 * constants.MENU_SCALE,
                                    16 * constants.MENU_SCALE),
                            size=5 * constants.MENU_SCALE,
                            color=constants.GRAY,
                            text=[
                                "WASD, ARROWS       MOVE",
                                "Z, SPACE, ENTER    SELECT/OPEN INVENTORY",
                                "X, ESCAPE          BACK/EXIT",
                                "TAB                OPEN/CLOSE INVENTORY"
                            ]))
Exemple #4
0
    def __init__(self, item, **kwargs):
        super().__init__(**kwargs)
        self.camera = self.parent.parent.camera
        self.world = self.parent.parent.world
        self.item = item
        self.dir = (0, 0)
        self.targettile = None
        self.droptile = None

        self.help_pos = DynamicPos(
            (self.game.width // 2,
             self.game.height + constants.MENU_SCALE * 2.5),
            speed=10)
        self.help_pos.move((self.help_pos.x, self.game.height / 2 +
                            constants.TILE_SIZE * constants.MENU_SCALE))

        text_args = {
            "renderer": self.game.renderer,
            "size": 5 * constants.MENU_SCALE,
            "centered": True
        }

        self.help_text = (wgt.Text(**text_args,
                                   text="Pick a direction",
                                   offset=(0, 0),
                                   color=constants.LIGHT_GRAY),
                          wgt.TextLines(**text_args,
                                        text=["Z to throw", "X to cancel"],
                                        offset=(0, 7 * constants.MENU_SCALE)))
Exemple #5
0
 def __init__(self, options, pos, **kwargs):
     super().__init__(**kwargs)
     self.options = options
     self.pos = pos
     self.cursor_pos = 0
     self.text = self.options_widget = wgt.TextLines(
         renderer=self.game.renderer,
         text=self.options,
         v_spacing=1.6,
         size=constants.MENU_SCALE * 5,
         offset=self.pos,
         centered=True)
Exemple #6
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.active = False

        self.debug_text = wgt.TextLines(
            renderer=self.game.renderer,
            size=10,
            v_spacing=1.2,
            color=constants.RED,
            offset=(0, 12),
        )
Exemple #7
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.config = config.Config()
        x = self.game.width // 2 - constants.MENU_SCALE * 200
        y = self.game.height // 2 - constants.MENU_SCALE * 120
        width = constants.MENU_SCALE * 400
        height = constants.MENU_SCALE * 240
        self.box_rect = pygame.Rect(x, y, width, height)
        self.border_size = constants.MENU_SCALE * 4

        self.widgets = [
            wgt.Text(renderer=self.game.renderer,
                     text="Settings",
                     offset=(self.box_rect.centerx,
                             self.box_rect.top + constants.MENU_SCALE * 15),
                     size=constants.MENU_SCALE * 10,
                     color=constants.DARK_GREEN,
                     centered=True),
            wgt.TextLines(
                renderer=self.game.renderer,
                text=[
                    "This menu is a work in progress.",
                    "Graphics settings will take effect on a game restart."
                ],
                offset=(self.box_rect.centerx,
                        self.box_rect.bottom + constants.MENU_SCALE * 15),
                size=constants.MENU_SCALE * 5,
                color=constants.LIGHT_GRAY,
                centered=True)
        ]
        self.options = []
        self.option_index = None

        toggle_pos = (self.box_rect.left + 10 * constants.MENU_SCALE,
                      self.box_rect.top + 40 * constants.MENU_SCALE)
        toggle = self.add_child_scene(Toggle,
                                      "Fullscreen",
                                      toggle_pos,
                                      state=self.config.fullscreen_mode)
        toggle.connect_signal("changed_state",
                              lambda x: self.set_setting("fullscreen_mode", x))
        self.options.append(toggle)
Exemple #8
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.visible = False
        self.cursorpos = [0, 0]
        self.size = [2, 5]
        self.slot_size = constants.TILE_SIZE * constants.MENU_SCALE
        self.pos = DynamicPos((-self.slot_size * 2 - 21,
                               self.game.height / 2 - self.slot_size * 3),
                              speed=10)
        self.image_grid_pos = [0, 0]

        self.widgets = [
            wgt.TextLines(renderer=self.game.renderer,
                          size=5 * constants.MENU_SCALE,
                          offset=(0, -19 * constants.MENU_SCALE),
                          text=["Z to select", "X to return"])
        ]

        self.add_child_scene(ImageGrid,
                             grid_size=self.size,
                             image=self.game.renderer.get_image(
                                 name="inventory-slot",
                                 scale=constants.MENU_SCALE),
                             pos=self.image_grid_pos)