def win_screen(gameDisplay, player): music_player = music.Music_Player() music_player.play_victory music_player.set_volume(0.5) music_choice.win() gameDisplay.fill(config.black) buttons = [ Button("QUIT", config.white, config.SPOOKY_SMALL_FONT, ((config.display_width / 2), (config.display_height / 1.2)), gameDisplay), ] text = f'Congratulations, {player.character}! You have escaped from the depths of Davis Hall.... \n Or have you? To be continued....' while True: format_text.blit_text(gameDisplay, text, (config.display_width/1.5, config.display_height), (config.display_width/2.5, config.display_height/5), config.SPOOKY_SMALL_FONT, config.red) for event in pygame.event.get(): if (event.type == pygame.QUIT or (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and buttons[0].text == "QUIT" and buttons[0].rect.collidepoint (pygame.mouse.get_pos()))): pygame.quit() quit() for button in buttons: Button.check_Hover(button, gameDisplay) pygame.display.update() clock.tick(15)
def game_start(player, gameDisplay): music_player = music.Music_Player() music_player.play_ambtrack5() w, h = pygame.display.get_surface().get_size() gameDisplay = transitions.transistion_character_selection_gameplay( pygame.display.get_surface(), player) gameDisplay.fill(config.black) buttons = [ Button("BACK", config.blue, pygame.font.Font("assets/fonts/CHILLER.ttf", 70), (90, 60), gameDisplay), ] utilities.set_image("assets/images/Menu_Mockup_1.1.jpg", gameDisplay) map = map_blit.Map("View Map", (700, 0)) map.blit(gameDisplay) while True: for event in pygame.event.get(): if (event.type == pygame.QUIT): pygame.quit() quit() elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and buttons[0].rect.collidepoint(pygame.mouse.get_pos())): main_menu() elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and map.rect.collidepoint(pygame.mouse.get_pos())): map.enter(gameDisplay) for button in buttons: Button.check_Hover(button, gameDisplay) map.check_hover() pygame.display.update() clock.tick(15)
def death(): global dead if not dead: encounter.boss_flag = False encounter.boss_defeated = False encounter.enemy_selected = False config.boss_initiate = False music_player = music.Music_Player() music_player.play_ambtrack8() dead = True
def encounter_choice(enemy): global dead dead = False if enemy.type == "Ethan": music_player = music.Music_Player() music_player.play_boss5() if current_enemy != enemy and encounter.music_steps > 50000: music_player = music.Music_Player() type = enemy.type if type == "220 Student": music_player.play_enemy1() if type == "AI Violation Email": music_player.play_enemy2() if type == "Deadline": music_player.play_enemy4() if type == "DJ Khaled": music_player.play_enemy3() if type == "Wet Floor Sign": music_player.play_enemy5() encounter.music_steps = 0
def start_game_play(player, gameDisplay): print(111111111111111111) w, h = pygame.display.get_surface().get_size() music_player = music.Music_Player() music_player.play_ambtrack2() gameDisplay.fill(config.black) buttons = [ Button("BACK", config.white, pygame.font.Font("assets/fonts/CHILLER.ttf", 70), (90, 60), gameDisplay) ] gui = pygame.Surface((w, h)) while True: for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: global paused paused = True print(420420420) utilities.pause() #if s button is pressed save the character's stats if event.key == pygame.K_s: print('saved the game') utilities.save(player) #if l button is pressed load the character's stats if event.key == pygame.K_l: utilities.load() player.pos = utilities.loaddata['pos'] player.health = utilities.loaddata['health'] player.actions = utilities.loaddata['actions'] player.items = utilities.loaddata['items'] player.hp = utilities.loaddata['hp'] elif (event.type == pygame.QUIT): pygame.quit() quit() elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and buttons[0].rect.collidepoint(pygame.mouse.get_pos())): pass # main_menu() # for button in buttons: # Button.check_Hover(button, gameDisplay) pygame.display.update() gui.fill(config.white) gameDisplay.blit(gui, (0, 0)) game_start(player, gameDisplay) clock.tick(15)
from character import Character, create_all_characters, random_character from enemies import Enemy, random_enemy #from assets import character_images from os import listdir from os.path import isfile, join import map_blit import transitions from assets import character_images import intro_screen import utilities from main_menu import main_menu pygame.init() paused = False music_player = music.Music_Player() music_player.set_volume(1.0) gameDisplay = pygame.display.set_mode( (config.display_width, config.display_height)) pygame.display.set_caption('Davis Hall Escape Simulator 2020') clock = pygame.time.Clock() def roundup(x): return int(math.ceil(x / 10.0)) * 10 if __name__ == "__main__": main_menu(gameDisplay, music_player) quit()
def win(): music_player = music.Music_Player() music_player.play_ambtrack10()
def options_menu(gameDisplay): music_player = music.Music_Player() music_player.play_options() w, h = pygame.display.get_surface().get_size() gameDisplay.fill(config.black) #buttons = [Button("BACK", white, SPOOKY_SMALL_FONT, (0,0))] current_volume = music_player.get_volume() volumeDisplay = Button(str(roundup(math.trunc(current_volume * 100))), config.white, config.SPOOKY_SMALL_FONT, (config.display_width /2 , config.display_height /2) ,gameDisplay) volume = Button("VOLUME", config.white, config.SPOOKY_SMALL_FONT, (volumeDisplay.pos[0] - 200, volumeDisplay.pos[1]) ,gameDisplay) buttons =[Button("BACK", config.white, pygame.font.Font("assets/fonts/CHILLER.ttf", 70), (90, 60), gameDisplay), Button("<", config.white, config.SPOOKY_SMALL_FONT, (config.display_width / 2 - 80, config.display_height / 2), gameDisplay), Button(">", config.white, config.SPOOKY_SMALL_FONT, (config.display_width / 2 + 80, config.display_height / 2), gameDisplay), Button("MUTE", config.white, config.SPOOKY_SMALL_FONT, (config.display_width / 2, config.display_height / 2 + 100), gameDisplay), Button("1280 x 768", config.white, config.SPOOKY_SMALL_FONT, (config.display_width / 2, config.display_height / 2 - 200), gameDisplay), Button("1400 x 900", config.white, config.SPOOKY_SMALL_FONT, (config.display_width / 2, config.display_height / 2 - 100), gameDisplay), Button("Save", config.white, config.SPOOKY_SMALL_FONT, (config.display_width / 2, config.display_height / 2 + 200), gameDisplay), Button("Load", config.white, config.SPOOKY_SMALL_FONT,(config.display_width / 2, config.display_height / 2 + 300), gameDisplay) ] while True: for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if (event.key == pygame.K_p): print(1111111111) return elif (event.type == pygame.QUIT): pygame.quit() quit() elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and buttons[0].rect.collidepoint( pygame.mouse.get_pos())): # if(config.paused == True): # print("proceeding to character selection function") # character_selection(gameDisplay) if(config.paused == False): return elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and buttons[1].rect.collidepoint( pygame.mouse.get_pos())): if (buttons[3].text != "UNMUTE"): music_player.set_volume(current_volume - 0.10) # Subtracting two floats isn't exact so multiply by 100 then truncate if (math.trunc(current_volume * 100) > 0): current_volume -= 0.10 # Need to re-render button reRenderVol(volumeDisplay, volume, str(roundup(math.trunc(current_volume * 100))), gameDisplay) elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and buttons[2].rect.collidepoint( pygame.mouse.get_pos())): if (buttons[3].text != "UNMUTE" and current_volume <= 100): music_player.set_volume(current_volume + 0.10) if (math.trunc(current_volume * 100) < 100): current_volume += 0.10 reRenderVol(volumeDisplay, volume, str(roundup(math.trunc(current_volume * 100))), gameDisplay) elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and buttons[3].text == "MUTE" and buttons[ 3].rect.collidepoint(pygame.mouse.get_pos())): music_player.set_volume(0.0) buttons[3].text = "UNMUTE" reRenderVol(volumeDisplay, volume, str(roundup(math.trunc(current_volume * 100))), gameDisplay) elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and buttons[3].text == "UNMUTE" and buttons[3].rect.collidepoint(pygame.mouse.get_pos())): music_player.set_volume(current_volume) buttons[3].text = "MUTE" reRenderVol(volumeDisplay, volume, str(roundup(math.trunc(current_volume * 100))), gameDisplay) elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and buttons[4].text == "1280 x 768" and buttons[4].rect.collidepoint(pygame.mouse.get_pos())): config.display_width = 1280 config.display_height = 768 pygame.display.set_mode((config.display_width, config.display_height)) pygame.transform.scale(gameDisplay, (config.display_width, config.display_height)) pygame.display.update() elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and buttons[5].text == "1400 x 900" and buttons[5].rect.collidepoint(pygame.mouse.get_pos())): config.display_height = 1400 config.display_height = 900 pygame.display.set_mode((config.display_width, config.display_height)) pygame.transform.scale(gameDisplay, (config.display_width, config.display_height)) pygame.display.update() pygame.transform.scale(gameDisplay, (config.display_width, config.display_height)) for button in buttons: Button.check_Hover(button, gameDisplay) pygame.display.update() clock.tick(15)
def character_selection(gameDisplay): print("selecting characters") w, h = pygame.display.get_surface().get_size() music_player = music.Music_Player() music_player.play_ambtrack9() gameDisplay.fill(config.black) buttons = [Button("BACK", config.white, pygame.font.Font("assets/fonts/CHILLER.ttf", 70), (90, 60), gameDisplay)] character_list = create_all_characters() selection_gui = pygame.Surface((w, h)) image_list, character_types = get_image_list() image_rect_list = [] num_of_images = len(image_list) + 1 start_x = 0 start_y = 0 x_offset = int(w / num_of_images) char_detail_surf, char_detail_rect = pygame.Surface((0,0)), pygame.Surface((0,0)) # init to random surface to avoid crash on line 2016 for elem in image_list: transformed_image = transform_image(elem, w, h, num_of_images) image_rect_list.append(set_image_location(transformed_image, start_x, start_y)) start_x += x_offset char_detail_offset = start_x while True: for event in pygame.event.get(): if (event.type == pygame.QUIT): pygame.quit() quit() elif (selection_gui.get_rect().collidepoint(pygame.mouse.get_pos())): index = 0 for char_image, char_rect in image_rect_list: if (char_rect.collidepoint(pygame.mouse.get_pos())): character = Character(character_types[index]) size = (x_offset, h) char_detail_surf = get_player_stats(character, size) break index += 1 #back button when clicked returns to main menu if (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and buttons[0].rect.collidepoint( pygame.mouse.get_pos())): return elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1): index = 0 for char_image, char_rect in image_rect_list: if (char_rect.collidepoint(event.pos)): print("character selected") character = Character(character_types[index]) player = Player(character) save(player) game_start(player, gameDisplay) index += 1 elif (selection_gui.get_rect().collidepoint(pygame.mouse.get_pos())): index = 0 for char_image, char_rect in image_rect_list: if (char_rect.collidepoint(pygame.mouse.get_pos())): character = Character(character_types[index]) size = (x_offset, h) char_detail_surf = get_player_stats(character, size) break index += 1 for button in buttons: Button.check_Hover(button, gameDisplay) pygame.display.update() selection_gui.fill(config.white) selection_gui.blit(char_detail_surf, (char_detail_offset, 10)) for image, image_rect in image_rect_list: selection_gui.blit(image, image_rect) gameDisplay.blit(selection_gui, (0, 0)) TextSurf, TextRect = render_text("Choose a Character", config.SPOOKY_BIG_FONT, config.red) TextRect.center = ((round(config.display_width / 2)), (round(config.display_height * .9))) gameDisplay.blit(TextSurf, TextRect) clock.tick(15)