-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
276 lines (226 loc) · 9.56 KB
/
main.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
import pygame
from camera import *
from title import Title
from animation import Animation
from intro1 import Intro1
from intro2 import Intro2
from diologue import Dialogue
from game import Game
from slideshow import Slideshow
from chase import ChaseGame
TOTAL_LIVES = 10
HP_WIDTH = 600
DISPLAY_W, DISPLAY_H = 1280, 720
pygame.mixer.pre_init()
pygame.init()
class GameStateController():
"main main main"
def __init__(self):
pygame.mixer.music.load("assets/music/colyon-clip.ogg")
pygame.mixer.music.set_volume(0.7)
pygame.mixer.music.play(-1,0.0)
self.woman_cry = pygame.mixer.Sound("assets/se/woman_cry.ogg")
self.woman_can_cry = True
self.woman_cry.set_volume(0.3)
self.roar = pygame.mixer.Sound("assets/se/roar.ogg")
self.can_roar = True
self.roar.set_volume(0.4)
self.screen = pygame.Surface((DISPLAY_W,DISPLAY_H))
self.window = pygame.display.set_mode((DISPLAY_W,DISPLAY_H))
self.title_screen = Title("assets/images/KH_Title.png")
self.intro1 = Intro1(self.screen, 1)
self.intro2 = Animation("assets/images/intro/2", self.screen)
self.intro3 = Intro2(self.screen)
self.intro4 = Animation("assets/images/intro/4", self.screen, 200, True)
self.intro5 = Dialogue("assets/images/intro/5")
self.intro6 = Dialogue("assets/images/intro/6")
self.intro7 = Dialogue("assets/images/intro/7")
self.intro8 = Slideshow("assets/images/intro/8", (0.5,1,1,1), 1000)
self.intro9 = Animation("assets/images/intro/9", self.screen, 500, False)
self.intro10 = Animation("assets/images/intro/10", self.screen, 200, False)
self.intro11 = Animation("assets/images/intro/11", self.screen, 200, False)
self.intro12 = Animation("assets/images/intro/12", self.screen, 400, False)
self.intro13 = Dialogue("assets/images/intro/13")
self.level1 = Game(self.screen, self.window, 1)
self.level2 = Game(self.screen, self.window, 2)
self.level3 = Game(self.screen, self.window, 3)
self.level4 = ChaseGame()
self.clock = pygame.time.Clock()
self.state = "title"
self.FPS = 60
self.can_switch_music1 = True #fadeout
self.can_switch_music2 = True #new music lions
self.done = False
def update_state(self):
if self.title_screen.done:
self.state = "intro1"
if self.intro1.done:
self.state = "intro2"
if not self.intro2.running:
self.state = "intro3"
if self.intro3.done:
self.state = "intro4"
if not self.intro4.running:
self.state = "intro5"
if self.intro5.done:
self.state = "level1"
if self.level1.done:
self.state = "intro6"
if self.woman_can_cry:
self.level1.bark.stop()
self.woman_cry.play()
self.woman_can_cry = False
if self.intro6.done:
self.state = "level2"
if self.level2.done:
self.state = "intro7"
if self.can_switch_music1:
pygame.mixer.music.fadeout(3000)
self.can_switch_music1 = False
if self.intro7.done:
if self.can_switch_music2:
pygame.mixer.stop()
pygame.mixer.music.load("assets/music/kh-lion-long.ogg")
pygame.mixer.music.set_volume(0.7)
pygame.mixer.music.play(-1,0.0)
self.can_switch_music2 = False
self.state = "intro8"
if self.intro8.done:
self.state = "intro9"
if not self.intro9.running:
self.state = "intro10"
if not self.intro10.running:
self.state = "intro11"
if not self.intro11.running:
self.state = "intro12"
if self.can_roar:
self.roar.play()
self.can_roar = False
if not self.intro12.running:
self.state = "level3"
if self.level3.done:
self.state = "intro13"
if self.intro13.done:
self.state = "level4"
def main_loop(self):
while not self.done:
# print(self.state)
self.update_state()
if self.state == "title":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.title_screen.check_events(event)
self.title_screen.run(self.screen)
elif self.state == "intro1":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro1.check_events(event)
self.intro1.update(self.screen)
elif self.state == "intro2":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro2.check_events(event)
self.intro2.run()
elif self.state == "intro3":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro3.check_events(event)
self.intro3.update(self.screen)
elif self.state == "intro4":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro4.check_events(event)
self.intro4.run()
elif self.state == "intro5":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro5.check_events(event)
self.intro5.run(self.screen)
elif self.state == "level1":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.level1.check_events2(event)
self.screen.fill((0,0,0))
# if self.state == "game":
self.level1.game_loop()
elif self.state == "intro6":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro6.check_events(event)
self.intro6.run(self.screen)
elif self.state == "level2":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.level2.check_events2(event)
self.screen.fill((0,0,0))
self.level2.game_loop()
elif self.state == "intro7":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro7.check_events(event)
self.intro7.run(self.screen)
elif self.state == "intro8":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro8.check_events(event)
self.intro8.run(self.screen)
elif self.state == "intro9":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro9.check_events(event)
self.intro9.run()
elif self.state == "intro10":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro10.check_events(event)
self.intro10.run()
elif self.state == "intro11":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro11.check_events(event)
self.intro11.run()
elif self.state == "intro12":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro12.check_events(event)
self.intro12.run()
elif self.state == "level3":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.level3.check_events2(event)
self.screen.fill((0,0,0))
# if self.state == "game":
self.level3.game_loop()
elif self.state == "intro13":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.intro13.check_events(event)
self.intro13.run(self.screen)
elif self.state == "level4":
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.done = True
self.level4.run(self.screen)
self.window.blit(self.screen, (0,0))
self.clock.tick(self.FPS)
pygame.display.update()
pygame.display.set_caption("[Pyweek38] Knight's Honor by speedlimit35 (FPS: "+str(int(self.clock.get_fps()))+")")
my_game = GameStateController()
my_game.main_loop()