예제 #1
0
 def choose_image(self):
     self.folder = str(Af.randint(1, 4))
     if self.folder == "4":
         self.image = Af.load_image(f"obstacles/4/{Af.randint(1, 11)}.png")
     else:
         self.image = Af.load_image(f"obstacles/{self.folder}/1.png")
     self.hit_box = pygame.mask.from_surface(self.image)
     self.rect = self.image.get_rect()
예제 #2
0
 def activate_fire(self, fire_type):
     if self.last_fire != fire_type:
         self.last_fire = fire_type
         self.fire_image_time = 0
     if self.fire_image_time < 1:
         self.fire_image_time += 1
     if fire_type:
         Af.play(fire_sound)
         self.fire_image = Af.load_image("cars/car effects/nitro/blue.png")
     else:
         self.fire_image = Af.load_image("cars/car effects/nitro/red.png")
예제 #3
0
 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")
예제 #4
0
 def __init__(self, screen, mode=False):
     self.screen = screen
     self.speed_meter_image = Af.load_image("HUD/meter/7.png")
     self.precision_meter_image = Af.load_image("HUD/meter/7.png")
     self.background = Af.load_image("HUD/HUD_background.png")
     self.speed = 0
     self.precision = 0
     self.energy = 0
     self.resistance = 0
     self.parts = 0
     self.mode = mode
     if mode:
         self.time = "infinite"
     else:
         self.time = 60
     self.set_up_HUD()
예제 #5
0
def tutorial(screen: Af.Surface):
    Af.play(change_menu_sound)
    position_x_tutorial = (1080 - 260) // 2
    position_y_tutorial = [y for y in range(110, 600, 100)]
    effects_tutorial = ["controls", "save", "enemy", "level_up", "game_menu"]
    buttons = [
        mc.Button(position_x_tutorial, y,
                  f"menu/buttons/4/{position_y_tutorial.index(y) + 1}.png",
                  effects_tutorial[position_y_tutorial.index(y)])
        for y in position_y_tutorial[:len(effects_tutorial)]
    ]
    button_coo = {
        0: (680, 90),
        1: (680, 90),
        2: (698, 192),
        3: (685, 178),
        4: (685, 178)
    }
    effects = [Af.load_image(f"menu/effects/1/{i + 1}.png") for i in range(4)]
    user = mc.User()
    user.get_active_user()
    user.get_texts()
    tutorial_menu = mc.User_Menu(screen, f"menu/interfaces/Main/tutorial.png",
                                 buttons, button_coo, effects, user)
    Af.write_file_content(
        "parameters/prev_men.txt",
        "game_menu")  # make sure any submenu returns to Game Menu after
    return tutorial_menu.display_menu()
예제 #6
0
def missions(screen: Af.Surface):
    Af.play(change_menu_sound)
    y_coo = [y for y in range(107, 600, 80)]
    effects_game = [
        "m_endless", "m_aim", "missions", "missions", "missions", "game_menu"
    ]
    buttons = Af.create_buttons(mc.Button, "menu/buttons/11", effects_game,
                                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()
    missions_menu = mc.User_Menu(screen,
                                 f"menu/interfaces/Main/missions menu.png",
                                 buttons, effects_coo, effects, user)
    next_link = missions_menu.display_menu()
    Af.write_file_content(
        "parameters/prev_men.txt",
        "game_menu")  # make sure any submenu returns to Game Menu after
    return next_link
예제 #7
0
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
예제 #8
0
 def __init__(self):
     self.images = [
         Af.load_image(f"Characters/Space-Time Entity/{i + 1}.png")
         for i in range(6)
     ]
     self.draw_lightning = False
     self.already_hit_target = False
     self.lightning = Lightning()
     self.index = 0
예제 #9
0
def main_menu(screen: Af.Surface):
    Af.stop_all_sounds()
    Af.play(change_menu_sound)
    buttons = Af.create_buttons(mc.Button, "menu/buttons/1",
                                ["choose", "new", "exit1"])
    button_coo = {0: (680, 90), 1: (698, 192), 2: (685, 178)}
    effects = [Af.load_image(f"menu/effects/1/{i + 1}.png") for i in range(4)]
    m_m = mc.Basic_Menu(screen, f"menu/interfaces/Main/main menu.png", buttons,
                        button_coo, effects)
    return m_m.display_menu()
예제 #10
0
 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
예제 #11
0
 def __init__(self, x, type_p, y, cardinality):
     self.type_p = type_p
     self.adjust = 15
     self.y_middle = y + self.adjust
     self.y = self.y_middle + cardinality
     self.x = x
     self.value = self.type_p**2
     self.image = Af.load_image(f"parts/part{self.type_p}.png")
     self.hit_box = pygame.mask.from_surface(self.image)
     self.rect = self.image.get_rect()
     self.length = 32
     self.movement_module = 10
     self.upwards = True
예제 #12
0
 def mover(self):
     init_m, nxt = 650, 20
     change = {
         init_m: f"/obstacles/{self.folder}/2.png",
         init_m - nxt: f"/obstacles/{self.folder}/3.png",
         init_m - nxt * 2: f"/obstacles/{self.folder}/4.png",
         init_m - nxt * 3: f"/obstacles/{self.folder}/5.png",
         init_m - nxt * 4: f"/obstacles/{self.folder}/6.png",
         init_m - nxt * 5: f"/obstacles/{self.folder}/7.png"
     }
     self.x -= 10
     if self.x in change and self.folder != "4":
         self.image = Af.load_image(change[self.x])
예제 #13
0
 def __init__(self, screen):
     self.screen = screen
     self.background = Af.load_image("HUD/HUD_background.png")
     # Game objects
     self.sp_ti_entity = ce.Space_Time_Entity()
     self.car = ce.Car()
     self.road = ce.Road()
     self.obstacles_list = ce.Obstacles()
     self.parts_list = ce.Parts()
     self.parts_collected = 0
     # HUD stuff
     self.energy = 100
     self.resistance = 100
     self.hud = ce.HUD(self.screen)
     self.speed = 0
     self.precision = 100
     # text stuff
     self.cursor = Af.load_image("texts/cursor.png")
     self.written_text = [[""]]
     self.text_name = None
     self.text_to_write_image = None
     image = Af.get_text_images("")
     self.written_text_images = [image, image, image, image, image, image, image, image]
     self.line = 0
     self.max_lines = 8
     self.total_words = 0.0
     self.correct_letters = 0
     self.current_word_index = 0
     self.text_to_write = None
     self.set_up_texts(True)
     # sound stuff
     self.play_tic_toc = True
     # loop stuff
     self.terminate = False
     self.clock = pygame.time.Clock()
     self.run = True
     self.time_passed = 0
     self.choice = None
예제 #14
0
 def __init__(self, screen_i):
     self.screen = screen_i
     # Game objects
     self.car = ce.Car()
     self.road = ce.Road()
     self.obstacles_list = ce.Obstacles()
     self.parts_list = ce.parts()
     self.parts_collected = 0
     self.individual = None
     self.hud_image = Af.load_image("HUD/HUD_background.png")
     # loop stuff
     self.clock = pygame.time.Clock()
     self.frame_rate = Af.FRAME_RATE  # must not be multiple of 10
     self.run = True
     self.time_passed = 0
     self.total_time = 0.0
     self.choice_delay = 0
     self.choice = None
     self.resistance = True
예제 #15
0
 def display_countdown(self):
     count_down_images = [Af.load_image(f"HUD/count_down/{image_index}.png") for image_index in range(4)]
     next_image, time_passed = 1, 0
     coordinates = {0: (440, 150), 1: (440, 150), 2: (450, 160), 3: (400, 150)}
     Af.play(count_down_sound)
     while time_passed < 4.5:
         self.clock.tick(Af.FRAME_RATE)
         time_passed += 0.034
         current_image_index = int(time_passed)
         try:
             self.refresh_game((count_down_images[current_image_index], coordinates[current_image_index]))
         except IndexError:
             self.refresh_game()
             continue
         if current_image_index == next_image:
             if next_image< 3:
                 Af.play(count_down_sound)
             else:
                 Af.play(start_sound)
             next_image += 1
     pygame.event.clear()  # all pressed buttons are dismissed in this phase
     Af.play(go_sound)
     Af.play_music()
예제 #16
0
def management_user(screen: Af.Surface):
    Af.write_file_content(
        "parameters/prev_men.txt",
        "manage")  # make sure any submenu returns to management after
    Af.play(change_menu_sound)
    y_coo = [110, 190, 270, 510]
    effects = ["change_password", "delete_account", "manage_us", "manage"]
    buttons = Af.create_buttons(mc.Button, "menu/buttons/12", effects, y_coo)
    effects_coo = {
        0: (687, 90),
        1: (687, 90),
        2: (687, 192),
        3: (687, 178),
        4: (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()
    directory = "menu/interfaces/Main/management_account.png"  # directory for the background image of the menu
    m_user_menu = mc.User_Menu(screen, directory, buttons, effects_coo,
                               effects, user)
    next_link = m_user_menu.display_menu()
    return next_link