-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
48 lines (37 loc) · 1.01 KB
/
example.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
import state as StateManagment
class Game:
def __init__(self):
self.states = ("state_1", "state_2")
state_dict = {
self.states[0]: StateManagment.ExampleState1,
self.states[1]: StateManagment.ExampleState2
}
self.game_state = StateManagment.StateMachine(self, state_dict)
self.game_state.change('state_1')
@staticmethod
def close():
exit()
def print_state_list(self):
print("*" * 20)
print("States list:")
for s in self.states:
print("--" + s)
print("*" * 20)
def run(self):
print("Welcome!")
self.print_state_list()
while True:
self.update()
print()
self.draw()
def update(self):
self.game_state.update()
def draw(self):
self.game_state.draw()
if __name__ == "__main__":
g = Game()
try:
g.run()
except KeyboardInterrupt:
print("\nPress enter to exit..")
input()