def choose_units_to_kill(window, fullscreen, units): window = create_window_of_Field(window, fullscreen, "Field") length = pygame.display.get_surface().get_width() width = pygame.display.get_surface().get_height() draw_button(window, (255, 215, 0), (100, 510, 600, 80), " Choose units", 85, 107, 47, 80) pygame.display.update() if len(units) > 4: buttons = draw_some_buttons(window, 4, [ units[0].base.name, units[1].base.name, units[2].base.name, units[3].base.name ], (0, 0, 100, 200), 255, 215, 0, 85, 107, 47, 20) # отступ между ними names = [] for i in units[4:]: names += [i.base.name] names += ["End"] buttons += draw_some_buttons(window, len(names), names, (700, 0, 100, 150), 255, 215, 0, 85, 107, 47, 20) # отступ между ними else: names = [] for i in units: names += [i.base.name] buttons = draw_some_buttons(window, len(names), names, (0, 0, 100, 200), 255, 215, 0, 85, 107, 47, 20) # отступ между ними buttons += draw_some_buttons(window, 1, ["End"], (700, 0, 100, 150), 255, 215, 0, 85, 107, 47, 20) # отступ между ними pygame.display.update() return buttons
def show_units(window, fullscreen, classes_list, arrays_list, class_name: str): """ :param arrays_list: :param classes_list: :param fullscreen: :param window: :param class_name: what class should be shown :return: buttons for units Create menu for information of Creatures """ create_window_of_the_same_size(window, fullscreen) length = pygame.display.get_surface().get_width() width = pygame.display.get_surface().get_height() unit_list = arrays_list[classes_list.index(class_name)] pygame.draw.rect(window, (205, 133, 63), (length // 8, width // 5, 3 * length // 4, 3 * width // 5 + 3 * width // 35)) buttons = draw_some_buttons( window, 7, unit_list[:7], (length // 8, width // 5, 3 * length // 8, 3 * width // 5)) buttons += draw_some_buttons( window, 7, unit_list[7:], (length // 2, width // 5, 3 * length // 8, 3 * width // 5)) buttons += draw_some_buttons( window, 1, ["Return"], (length // 3, 4 * width // 5 - 30, length // 3, width // 7)) pygame.display.update() return buttons, unit_list
def option_menu(window, fullscreen): """ :return: array of option's buttons """ size_of_options = [pygame.display.get_surface().get_width(), pygame.display.get_surface().get_height()] create_window_of_the_same_size(window, fullscreen) length = size_of_options[0] width = size_of_options[1] pygame.draw.rect(window, (205, 133, 63), (length // 3, width // 5, length // 3, 2 * width // 5 + (2 * width // 5 - 90) // 6 + 20)) if os.name == "nt": user32 = ctypes.windll.user32 current_w = user32.GetSystemMetrics(0) current_h = user32.GetSystemMetrics(1) else: info_object = str(get_monitors()).split("=") current_w = int(info_object[3].split(",")[0]) current_h = int(info_object[4].split(",")[0]) button_names = [] button_name = "800x600" if current_w < 800 or current_h < 600: button_name += "*" button_names += [button_name] button_name = "1178x663" if current_w < 1178 or current_h < 663: button_name += "*" button_names += [button_name] button_name = "1280x720" if current_w < 1280 or current_h < 720: button_name += "*" button_names += [button_name] button_name = "1920x1080" if current_w < 1920 or current_h < 1080: button_name += "*" button_names += [button_name] button_name = "1600x800" if current_w < 1600 or current_h < 800: button_name += "*" button_names += [button_name] button_names += ["Fullscreen", "Return"] buttons = draw_some_buttons(window, len(button_names), button_names, (length // 3, width // 5, length // 3, 2 * width // 5 + ( 2 * width // 5 - 90) // 6 + 20)) fond = pygame.font.Font(None, 40) text = fond.render("* means you can't choose this parametr", True, [255, 255, 255]) window.blit(text, [length // 4, width - 40]) pygame.display.update() return buttons
def create_window(window, fullscreen, length: int = 800, width: int = 600, update=True): """ :param window: where to drow :param fullscreen: is it fullscreen :param update: if it needs to be updated :param length: Length of screen :param width: Width of screen :return: array of buttons Creating window of game(depends on format) Make main buttons """ if os.name == "nt": user32 = ctypes.windll.user32 current_w = user32.GetSystemMetrics(0) current_h = user32.GetSystemMetrics(1) background_image = pygame.image.load( str(os.path.abspath(__file__)).split("Game")[0] + "textures/" + str(length) + "x" + str(width) + ".jpg") else: info_object = str(get_monitors()).split("=") current_w = int(info_object[3].split(",")[0]) current_h = int(info_object[4].split(",")[0]) background_image = pygame.image.load("textures/" + str(length) + "x" + str(width) + ".jpg") if current_w < length or current_h < width: print("you can't choose that. Default was set") length = 800 width = 600 if os.name == "nt": background_image = pygame.image.load( str(os.path.abspath(__file__)).split("Game")[0] + "textures/" + str(length) + "x" + str(width) + ".jpg") else: background_image = pygame.image.load( str(length) + "x" + str(width) + ".jpg") if fullscreen: window = pygame.display.set_mode((length, width), pygame.HWSURFACE | pygame.FULLSCREEN) else: window = pygame.display.set_mode((length, width)) window.blit(background_image, [0, 0]) pygame.display.set_caption("Герои меча и магии(Arthur's and Anastasia's " "remake)") pygame.draw.rect(window, (205, 133, 63), (length // 3, width // 3, length // 3, width // 3)) buttons = draw_some_buttons( window, 4, ["Start playing", "Options", "Information", "Exit"], (length // 3, width // 3, length // 3, width // 3)) if update: pygame.display.update() return window, buttons
def draw_commans(window, fullscreen): window = create_window_of_Field(window, fullscreen, "Field") length = pygame.display.get_surface().get_width() width = pygame.display.get_surface().get_height() draw_button(window, (255, 215, 0), (100, 510, 600, 80), " What do you want to do?", 85, 107, 47, 80) pygame.display.update() buttons = draw_some_buttons(window, 7, ["move", "attack", "move_attack", "Wait", "Defend", "Exit", "range_attack"], (0, 0, 100, 350), 255, 215, 0, 85, 107, 47, 20) return buttons
def show_heroes(window, fullscreen, class_name: str): """ :param class_name: Witch class should be shown :return: buttons coordinates Create Hero menu """ create_window_of_the_same_size(window, fullscreen) length = pygame.display.get_surface().get_width() width = pygame.display.get_surface().get_height() hero_list = heroes_list[classes_list.index(class_name)] pygame.draw.rect(window, (205, 133, 63), (length // 3, width // 3, length // 3, width // 3)) buttons = draw_some_buttons( window, 2, hero_list, (length // 3, width // 3, length // 3, 2 * width // 9)) buttons += draw_some_buttons( window, 1, ["Return"], (length // 3, width // 3 - 30 + 2 * width // 9, length // 3, width // 9 + 15)) pygame.display.update() return buttons, hero_list
def information_menu(window, fullscreen): """ :return: information buttons Create information window """ create_window_of_the_same_size(window, fullscreen) length = pygame.display.get_surface().get_width() width = pygame.display.get_surface().get_height() pygame.draw.rect(window, (205, 133, 63), (length // 3, width // 3, length // 3, width // 3)) buttons = draw_some_buttons( window, 4, ["Heroes", "Spells", "Units", "Return"], (length // 3, width // 3, length // 3, width // 3)) pygame.display.update() return buttons
def choose_mod(window, fullscreen): """ :return: buttons of choosing class Create a window to choose class """ create_window_of_the_same_size(window, fullscreen) length = pygame.display.get_surface().get_width() width = pygame.display.get_surface().get_height() pygame.draw.rect( window, (205, 133, 63), (3 * length // 8, width // 5, 3 * length // 8, 3 * width // 5)) buttons = draw_some_buttons( window, 2, ["Duel", "Return"], (3 * length // 8, width // 5, 3 * length // 8, 3 * width // 5)) pygame.display.update() return buttons
def choose_class_display(window, fullscreen): """ :return: buttons of choosing class Create a window to choose class """ create_window_of_the_same_size(window, fullscreen) length = pygame.display.get_surface().get_width() width = pygame.display.get_surface().get_height() pygame.draw.rect( window, (205, 133, 63), (3 * length // 8, width // 5, 3 * length // 8, 3 * width // 5)) buttons = draw_some_buttons(window, 7, [ "Orden", "Necropolis", "Inferno", "NatureProtection", "ShadowLeague", "Mage", "Return" ], (3 * length // 8, width // 5, 3 * length // 8, 3 * width // 5)) pygame.display.update() return buttons
def spell_menu(window, fullscreen): """ :return: spell menu buttons Create a spell menu """ create_window_of_the_same_size(window, fullscreen) length = pygame.display.get_surface().get_width() width = pygame.display.get_surface().get_height() pygame.draw.rect(window, (205, 133, 63), (length // 3, width // 3, length // 3, width // 3)) buttons = draw_some_buttons(window, 5, ["Dark", "Destructive", "Light", "Summoning", "Return"], (length // 3, width // 3, length // 3, width // 3)) pygame.display.update() return buttons
def create_window_choise(window, fullscreen, length: int = 800, width: int = 600, update=True): window = create_window_of_Field(window, fullscreen, "Field") draw_button(window, (255, 215, 0), (100, 510, 600, 80)) pygame.display.update() buttons = draw_some_buttons( window, 2, ["Orden", "Necropolis"], ( 100, 500, 200, # длина надписи 1 * width // 6), 255, 215, 0, 85, 107, 47, 28) # отступ между ними buttons += draw_some_buttons( window, 2, ["Inferno", "Nature Protection"], ( 300, 500, 200, # длина надписи 1 * width // 6), 255, 215, 0, 85, 107, 47, 28) # отступ между ними buttons += draw_some_buttons( window, 2, ["Shadow League", "Mage"], ( 500, 500, 200, # длина надписи 1 * width // 6), 255, 215, 0, 85, 107, 47, 28) # отступ между ними pygame.display.update() if update: pygame.display.update() return window, buttons