-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
76 lines (48 loc) · 1.63 KB
/
main.py
File metadata and controls
76 lines (48 loc) · 1.63 KB
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
import os
os.environ['KIVY_NO_CONSOLELOG'] = '1'
os.environ['KIVY_NO_FILELOG'] = '1'
os.environ["KIVY_NO_ARGS"] = "1"
os.environ["KIVY_DEBUG"] = "0"
from kivy.config import Config
Config.set('graphics', 'fullscreen', 'auto')
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from classes.Main import Main
import sys
import traceback
from kivy.resources import resource_add_path
def custom_excepthook(exctype, value, tb):
traceback.print_exception(exctype, value, tb)
sys.excepthook = custom_excepthook
if sys.stdout is None:
sys.stdout = open(os.devnull, 'w')
if sys.stderr is None:
sys.stderr = open(os.devnull, 'w')
def add_meipass_resource_path():
if hasattr(sys, "_MEIPASS"):
resource_add_path(os.path.join(sys._MEIPASS))
class InfiniteMap(App):
size_multiplier = 1.5
default_width = Window.width
default_height = Window.height
key = None
draw = None
position = None
player = None
main = None
def resource_path(self, relative_path):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative_path)
return os.path.join(os.path.abspath("."), relative_path)
def build(self):
Builder.load_file(self.resource_path("main.kv"))
try:
Window.size = (self.default_width, self.default_height)
self.main = Main()
self.main.start()
return self.main
except Exception as e:
print("\n\nError in 'InfiniteMap' Class - 'build' Function", e)
if __name__ == "__main__":
InfiniteMap().run()