1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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()
|