-
Notifications
You must be signed in to change notification settings - Fork 1
/
load_screen.py
102 lines (77 loc) · 2.96 KB
/
load_screen.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
from .. import setup, tools
from .. import constants as c
from .. import game_sound
from ..components import info
class LoadScreen(tools._State):
def __init__(self):
tools._State.__init__(self)
def startup(self, current_time, persist):
self.start_time = current_time
self.persist = persist
self.game_info = self.persist
self.next = self.set_next_state()
info_state = self.set_overhead_info_state()
self.overhead_info = info.OverheadInfo(self.game_info, info_state)
self.sound_manager = game_sound.Sound(self.overhead_info)
def set_next_state(self):
"""Sets the next state"""
return c.LEVEL1
def set_overhead_info_state(self):
"""sets the state to send to the overhead info object"""
return c.LOAD_SCREEN
def update(self, surface, keys, current_time):
"""Updates the loading screen"""
if (current_time - self.start_time) < 2400:
surface.fill(c.BLACK)
self.overhead_info.update(self.game_info)
self.overhead_info.draw(surface)
elif (current_time - self.start_time) < 2600:
surface.fill(c.BLACK)
elif (current_time - self.start_time) < 2635:
surface.fill((106, 150, 252))
else:
self.done = True
class GameOver(LoadScreen):
"""A loading screen with Game Over"""
def __init__(self):
super(GameOver, self).__init__()
def set_next_state(self):
"""Sets next state"""
return c.MAIN_MENU
def set_overhead_info_state(self):
"""sets the state to send to the overhead info object"""
return c.GAME_OVER
def update(self, surface, keys, current_time):
self.current_time = current_time
self.sound_manager.update(self.persist, None)
if (self.current_time - self.start_time) < 7000:
surface.fill(c.BLACK)
self.overhead_info.update(self.game_info)
self.overhead_info.draw(surface)
elif (self.current_time - self.start_time) < 7200:
surface.fill(c.BLACK)
elif (self.current_time - self.start_time) < 7235:
surface.fill((106, 150, 252))
else:
self.done = True
class TimeOut(LoadScreen):
"""Loading Screen with Time Out"""
def __init__(self):
super(TimeOut, self).__init__()
def set_next_state(self):
"""Sets next state"""
if self.persist[c.LIVES] == 0:
return c.GAME_OVER
else:
return c.LOAD_SCREEN
def set_overhead_info_state(self):
"""Sets the state to send to the overhead info object"""
return c.TIME_OUT
def update(self, surface, keys, current_time):
self.current_time = current_time
if (self.current_time - self.start_time) < 2400:
surface.fill(c.BLACK)
self.overhead_info.update(self.game_info)
self.overhead_info.draw(surface)
else:
self.done = True