-
Notifications
You must be signed in to change notification settings - Fork 1
/
__main__.py
69 lines (43 loc) · 1.37 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
"""Facility with function to run the Bionic Blue game.
Bionic Blue (by Kennedy Guerra): to know more about this game,
visit its website: https://bionicblue.indiepython.com
"""
### local imports
## first ensure pygame used is the community edition fork (pygame-ce);
##
## this is important because the app uses services that are not available
## in the regular pygame instance
from .ensurepygamece import ensure_pygame_ce
ensure_pygame_ce()
## remaining local imports
from .config import REFS
from .pygamesetup import SERVICES_NS, switch_mode
from .pygamesetup.gamepaddirect import setup_gamepad_if_existent
from .states import setup_states
from .exceptions import (
SwitchStateException,
BackToBeginningException,
SwitchModeException,
)
def run_game():
"""Run the game loop."""
setup_states()
state = REFS.states.resource_loader
setup_gamepad_if_existent()
running = True
while True:
try:
### game loop
while True:
SERVICES_NS.frame_checkups()
state.control()
state.update()
state.draw()
except SwitchStateException as obj:
state = obj.state
except BackToBeginningException as obj:
pass
except SwitchModeException as obj:
switch_mode(obj)
if __name__ == '__main__':
run_game()