Exemplo n.º 1
0
 def draw(self):
     pygame.draw.rect(self.surface, self.c_c_box, self.rect)
     draw_text(self.surface,
               self.button_text,
               self.center_coords,
               self.c_c_text,
               center=True)
Exemplo n.º 2
0
def menu_pause():
    # This Menu pauses the game and displays a simple message in the center of THE MAP (not the screen [danke markus
    # mit deinem vollbild kack :P])

    menu_close = False

    window_width = constants.CAMERA_WIDTH
    window_height = constants.CAMERA_HEIGHT

    menu_text = "PAUSED"
    menu_font = config.ASSETS.FONT_DEBUG_MESSAGE
    text_height, text_width = render_helper.helper_text_dimensions(menu_font)

    while not menu_close:

        events_list = pygame.event.get()

        for event in events_list:

            if event.type == pygame.KEYDOWN:

                if event.key == pygame.K_p:
                    menu_close = True

        render_helper.draw_text(config.SURFACE_MAIN, menu_text,
                                ((window_width / 2) - (text_width / 2), (window_height / 2) - (text_height / 2)),
                                constants.COLOR_BLACK, constants.COLOR_WHITE)

        config.CLOCK.tick(constants.GAME_FPS)

        # Man Muss das jedes mal updaten wenn man was malt
        pygame.display.flip()
Exemplo n.º 3
0
 def draw(self):
     pygame.draw.rect(self.surface, self.bg_color, self.bg_rect)
     pygame.draw.rect(self.surface, self.fg_color, self.fg_rect)
     pygame.draw.rect(self.surface, constants.COLOR_BLACK, self.grip_tab)
     draw_text(self.surface,
               self.string, (self.bg_rect.x, self.bg_rect.y - 30),
               constants.COLOR_BLACK,
               center=True)
Exemplo n.º 4
0
 def draw_messages(self):
     history_length = len(config.GAME.message_history)
     if history_length != self.message_history_old_length:
         config.SURFACE_MESSAGES.fill((0, 0, 0))
         to_draw = config.GAME.message_history[-constants.NUM_MESSAGES:]
         for i, (message, color) in enumerate(to_draw):
             render_helper.draw_text(config.SURFACE_MESSAGES, message,
                                     (0, i * self.text_height), color)
         config.GAME.message_history_old_length = history_length
Exemplo n.º 5
0
def death_player(player, killer_ent):
    print("HALLo")
    config.SURFACE_MAIN.fill(constants.COLOR_BLACK)

    screen_center = (constants.RECT_WHOLE_SCREEN.width / 2,
                     constants.RECT_WHOLE_SCREEN.height / 2)

    render_helper.draw_text(config.SURFACE_MAIN,
                            "lol nibba u dead!",
                            screen_center,
                            constants.COLOR_WHITE,
                            center=True)
    render_helper.draw_text(
        config.SURFACE_MAIN,
        "Check the legacy file to know what beat yo ass up",
        (constants.RECT_WHOLE_SCREEN.width / 2,
         constants.RECT_WHOLE_SCREEN.height / 2 + 100),
        constants.COLOR_WHITE,
        center=True)

    pygame.display.update()

    file_name = ("data/userdata/legacy_" + "." +
                 datetime.date.today().strftime("%Y%B%d") + ".txt")

    if os.path.isfile(file_name):
        os.remove(file_name)
    if os.path.isfile("data/userdata/savegame"):
        os.remove("data/userdata/savegame")

    legacy_file = open(file_name, "a+")

    for message, color in config.GAME.message_history:
        legacy_file.write(message + "\n")

    pygame.mixer.music.load(config.ASSETS.music_death)
    pygame.mixer.music.play()

    pygame.time.wait(12000)
    config.MAIN_MENU.show_menu()
Exemplo n.º 6
0
    def draw(self):
        pygame.draw.rect(self.surface, self.bg_color, self.rect)
        pygame.draw.rect(self.surface, self.fg_color, self.fg_rect)
        draw_text(self.surface,
                  self.print_text_format.format(self.string,
                                                self.current_value,
                                                self.max_value),
                  (self.rect.centerx, self.rect.centery),
                  self.text_color,
                  center=True,
                  font=config.ASSETS.FONT_FANTY)

        # if self.border:
        #    self.surface.blit(self.border, self.rect)
        self.mini_rect_w.top = self.rect.top
        pygame.draw.rect(self.surface, self.border_color, self.mini_rect_w)
        self.mini_rect_w.top = self.rect.bottom - self.mini_rect_w.height
        pygame.draw.rect(self.surface, self.border_color, self.mini_rect_w)
        self.mini_rect_h.left = self.rect.left
        pygame.draw.rect(self.surface, self.border_color, self.mini_rect_h)
        self.mini_rect_h.left = self.rect.right - self.mini_rect_h.width
        pygame.draw.rect(self.surface, self.border_color, self.mini_rect_h)
Exemplo n.º 7
0
    def show_main_menu(self):
        pygame.mixer.music.load(config.ASSETS.music_main_menu)
        pygame.mixer.music.play(-1)
        while self.menu_running:
            list_of_events = pygame.event.get()
            mouse_position = pygame.mouse.get_pos()

            game_input = (list_of_events, mouse_position)

            for event in list_of_events:
                if event.type == pygame.QUIT:
                    pygame.quit()
                    self.game_exit()

            self.button_container.react_multiple(game_input)

            self.button_container.draw()

            render_helper.draw_text(config.SURFACE_MAIN, self.title_text, (self.title_x, self.title_y),
                                    constants.COLOR_RED,
                                    center=True)

            pygame.display.update()
Exemplo n.º 8
0
 def draw(self):
     if self.bg_color:
         pygame.draw.rect(self.surface, self.bg_color, self.rect)
     draw_text(self.surface, self.static_text + str(self.value),
               (self.rect.x, self.rect.y), self.text_color)
Exemplo n.º 9
0
 def draw(self):
     pygame.draw.rect(self.surface, self.color, self.rect)
     draw_text(self.surface,
               self.text, (self.rect.x + 3, self.rect.y),
               self.text_color,
               font=self.font)
Exemplo n.º 10
0
def menu_inventory():
    # Initalize to False, when True, the menu closes
    menu_close = False

    # Calculate window dimensions
    window_width = constants.CAMERA_WIDTH
    window_height = constants.CAMERA_HEIGHT

    # Menu characteristics
    menu_width = 500
    menu_height = 400
    menu_x = (window_width / 2) - (menu_width / 2)
    menu_y = (window_height / 2) - (menu_height / 2)

    # Menu text characteristics
    menu_text_font = config.ASSETS.FONT_MESSAGE_TEXT

    # Helper var
    menu_text_height, _ = render_helper.helper_text_dimensions(menu_text_font)

    local_inventory_surface = pygame.Surface((menu_width, menu_height))

    while not menu_close:

        # Clear the menu
        local_inventory_surface.fill(constants.COLOR_BLACK)
        container = config.GAME.current_level.world.component_for_player(Container)
        print_list = ["Gold(" + str(container.gold) + ")"]
        for ent_item in container.inventory:
            print_list.append(config.GAME.current_level.world.component_for_entity(ent_item, Name).name)

        events_list = pygame.event.get()
        mouse_x, mouse_y = pygame.mouse.get_pos()

        mouse_x_rel = mouse_x - menu_x
        mouse_y_rel = mouse_y - menu_y

        mouse_in_window = (0 < mouse_x_rel < menu_width and
                           0 < mouse_y_rel < menu_height)

        pepegarechnung = mouse_y_rel / constants.INVENTORY_TEXT_HEIGHT
        mouse_line_selection = int(pepegarechnung)

        for event in events_list:

            if event.type == pygame.KEYDOWN:

                if event.key == pygame.K_i:
                    pygame.mixer.Channel(1).play(pygame.mixer.Sound("data/audio/soundeffects/leather_inventory.wav"))
                    menu_close = True

            if event.type == pygame.MOUSEBUTTONDOWN:
                if event.button == 1:
                    if mouse_in_window and mouse_line_selection <= len(print_list) - 1:
                        if mouse_line_selection > 0:
                            config.PLAYER.container.inventory[mouse_line_selection - 1].item.use()
                            menu_close = True

        ##Draw the list
        for line, name in enumerate(print_list):

            if int(line) == int(mouse_line_selection) and mouse_in_window:
                render_helper.draw_text(local_inventory_surface, name,
                                        (0, 0 + (line * constants.INVENTORY_TEXT_HEIGHT)),
                                        constants.COLOR_WHITE, constants.COLOR_GREY)

            else:
                render_helper.draw_text(local_inventory_surface, name,
                                        (0, 0 + (line * constants.INVENTORY_TEXT_HEIGHT)),
                                        constants.COLOR_WHITE)

        # Render Game
        render_helper.draw_menu()

        # Display Menu
        config.SURFACE_MAIN.blit(local_inventory_surface, (menu_x, menu_y))

        config.CLOCK.tick(constants.GAME_FPS)

        pygame.display.update()

    render_helper.fill_surfaces()
    map_helper.transition_reset()