def get_car_image(): try: level = Af.read_file_content("saves/active_user.txt", 1)[0].split(" ")[3] except IndexError: level = 21 return Af.load_image(f"cars/{level}.png")
def game_menu(screen: Af.Surface): Af.play(change_menu_sound) y_coo = [y for y in range(107, 600, 80)] b_effects = ["story", "m_ai", "missions", "tutorial", "manage", "exit2"] buttons = Af.create_buttons(mc.Button, "menu/buttons/2", b_effects, y_coo) effects_coo = { 0: (687, 90), 1: (687, 90), 2: (687, 192), 3: (687, 178), 4: (687, 178), 5: (687, 178) } effects = [Af.load_image(f"menu/effects/3/{i + 1}.png") for i in range(4)] user = mc.User() user.get_active_user() user.get_texts() g_menu = mc.Game_Menu(screen, f"menu/interfaces/Main/game menu.png", buttons, effects_coo, effects, user) next_link = g_menu.display_menu() if next_link == "m_ai": mission_is_unlocked = int( Af.read_file_content(f"saves/{user.name}/next_level.txt", 1)[0]) if not mission_is_unlocked: next_link = "nx_l" Af.write_file_content( "parameters/prev_men.txt", "game_menu") # make sure any submenu returns to Game Menu after return next_link
def set_up_texts(self, first=False): self.text_name = Af.choice(Af.get_text_names())[:-4] # chooses random text from existing texts self.text_to_write_image = Af.load_image(f"texts/{self.text_name}.png") # loads the text's image lines = Af.read_file_content(f"texts/{self.text_name}.txt") # loads the text's content self.text_to_write = [line.split(" ") for line in lines[1:]] # sets the text in proper format self.screen.blit(self.text_to_write_image, (280, 320)) image = Af.get_text_images("") # turns written text into images to display self.written_text_images = [image, image, image, image, image, image, image, image] self.written_text = [[""]] self.line = 0 # sets current line to 0 (beginning) self.max_lines = int(lines[0]) # gets the number of lines that the chosen text has
def delete_statistics(screen: Af.Surface): Af.play(change_menu_sound) buttons = [ mc.Button(240, 410, f"menu/buttons/3/1.png", True), mc.Button(580, 410, f"menu/buttons/3/2.png", False) ] if mc.Exit("menu/exit/delete_account.png", screen, buttons).display_menu(): user_name = Af.read_file_content("saves/active_user.txt", 1)[0].split(" ")[0] verification_password = mc.Enter_Password(screen, True).display_menu() if verification_password == "main_menu": Af.play(delete_account_sound) Af.delete_user_account(user_name) return verification_password return "manage_us"