-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
39 lines (31 loc) · 834 Bytes
/
run.py
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
# Created on 21 October 2019
import pygame as pg
from traceback import print_exc
import os
from sys import exit
from Tools import game_vars
from Tools.constants import load_fonts, resize, MIN_W, MIN_H
# Make sure all necessary folders exist
folders = ["res", "res/items", "res/items", "res/entities",
"saves", "saves/players/", "saves/universes/"]
for folder in folders:
if not os.path.exists(folder):
os.makedirs(folder)
# Do any initialization of variables and such
pg.init()
load_fonts()
resize(MIN_W, MIN_H)
game_vars.init()
clock = pg.time.Clock()
while True:
result = False
try:
result = game_vars.tick()
except:
print("Crashed", print_exc())
if not result:
game_vars.close_world()
pg.quit()
exit(0)
pg.display.flip()
clock.tick(60)