-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_core.py
149 lines (118 loc) · 3.9 KB
/
game_core.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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import PyQt5
from PyQt5 import QtCore, QtGui, QtWidgets
from main_shot import Ui_MainWindow
from menu_modul import Ui_MainMenu
from skins_or_skills_modul import UiSkinSkills
from window_modul import MyMainWindow
from data_modul import JsonConnector, SoundThread
from aftergame_modul import UiAfterGame
from character_modul import Postac
class GameCore(object):
ui = None
window = None
def start(self):
self.window = MyMainWindow()
self.show_main_menu()
self.window.showFullScreen()
self.start_menu_music()
# self.window.show()
def show_main_menu(self):
self.ui = Ui_MainMenu()
self.set_menu_config()
self.ui.setupUi(self.window)
def reload_main_menu(self):
self.ui.centralwidget.close()
del self.ui
self.show_main_menu()
self.window.resize_tlo()
self.ui.centralwidget.show()
def set_menu_config(self):
self.cls_game_config(self.ui, self.window)
Ui_MainMenu.core = self
self.window.ui = self.ui
@classmethod
def cls_game_config(cls, ui, window):
cls.ui = ui
cls.window = window
def set_game_config(self, ui, window):
self.cls_game_config(ui, window)
Postac.set_parrent_objects(window, ui)
Postac.core = self
self.window.ui = ui
self.ui.okno = window
def play_main_game(self):
self.reload_main_game()
self.stop_menu_music()
def reload_main_game(self):
self.ui.centralwidget.close()
del self.ui
self.ui = Ui_MainWindow()
self.set_game_config(self.ui, self.window)
self.ui.setupUi(self.window)
self.window.resize_tlo()
Postac.score = 0
self.ui.centralwidget.show()
self.window.main_game = True
Postac.start_enemy_clock()
self.music = SoundThread("shotMainSoundtrack.wav", True)
self.music.start()
def make_aftergame(self):
self.ui.centralwidget.close()
del self.ui
self.load_aftergame()
def load_aftergame(self):
self.ui = UiAfterGame()
self.set_aftergame_config()
self.ui.setupUi(self.window)
self.window.resize_tlo()
self.ui.centralwidget.show()
def set_aftergame_config(self):
self.cls_game_config(self.ui, self.window)
self.ui.core = self
self.window.ui = self.ui
def load_shop(self):
self.ui.centralwidget.close()
del self.ui
self.ui = UiSkinSkills()
self.shop_config()
self.ui.setupUi(self.window, "skins")
self.window.resize_tlo()
self.ui.centralwidget.show()
def shop_config(self):
self.window.ui = self.ui
self.cls_game_config(self.ui, self.window)
self.ui.core = self
def load_skills_menu(self):
self.ui.centralwidget.close()
del self.ui
self.ui = UiSkinSkills()
self.skills_menu_config()
self.ui.setupUi(self.window, "skills")
self.window.resize_tlo()
self.ui.centralwidget.show()
def skills_menu_config(self):
self.window.ui = self.ui
self.cls_game_config(self.ui, self.window)
self.ui.core = self
def player_death(self):
self.window.main_game = False
self.make_aftergame()
self.check_score()
self.music.stop()
x = SoundThread("shotError.wav")
x.start()
def check_score(self):
x = JsonConnector.get_from_config("highscore")
if x < Postac.score:
JsonConnector.save_key_to_config("highscore", Postac.score)
def start_menu_music(self):
self.menu_music = SoundThread("shotMenuSoundtrack.wav", loop=True)
self.menu_music.start()
def stop_menu_music(self):
self.menu_music.stop()
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
core = GameCore()
core.start()
sys.exit(app.exec_())