diff options
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 87 |
1 files changed, 87 insertions, 0 deletions
@@ -0,0 +1,87 @@ +from os import environ +environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1' + +import traceback +import os +os.chdir(os.path.dirname(os.path.realpath(__file__))) + +import pygame + +import sys +sys.path.append("./src") + +from src import audio, game, window, loader + +pygame.font.init() +pygame.init() + +window.init() +clock = pygame.time.Clock() +screen = pygame.display.set_mode((1280, 720), pygame.RESIZABLE) +running = True + +index = 0 + +played_audio = False +showing_load = True + +while running: + try: + pygame.display.flip() + screen.fill("black") + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + + if not played_audio: + audio.play_intro() + played_audio = True + + if showing_load: + if index <= 60: + screen.blit(pygame.transform.scale(loader.draw_texture(index), (180, 180)), (1280 / 2 - 180 / 2, 720 / 2 - 180 / 2)) + + index += 1 + + if index > 70: + showing_load = False + + pygame.display.flip() + + clock.tick(25) + else: + game.run(screen) + break + except Exception as e: + pygame.mixer.music.load("./assets/sounds/gui/error.ogg") + pygame.mixer.music.play() + pygame.mouse.set_visible(True) + + running = True + + if pygame.mixer.Channel(1).get_busy(): + pygame.mixer.Channel(1).pause() + + screen.fill((0, 0, 0)) + + img = pygame.image.load("./assets/textures/crash.png") + img.convert() + + screen.blit(pygame.transform.scale(img, (84, 84)), (100, 100)) + + message = e.message if hasattr(e, 'message') else str(e) + code = ("".join([hex(ord(i)).split("x")[1] for i in message]) + "00000000").upper() + screen.blit(pygame.font.Font("./assets/font/main.ttf", 20).render("An error has occurred and the game has stopped.", True, (255, 255, 255)), (200, 124)) + screen.blit(pygame.font.Font("./assets/font/main.ttf", 20).render("Error code: 0x" + code[0:8], True, (255, 255, 255)), (199, 144)) + + pygame.display.update() + + print(traceback.format_exc()) + + while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + +pygame.quit()
\ No newline at end of file |