summaryrefslogtreecommitdiff
path: root/cameltris
diff options
context:
space:
mode:
Diffstat (limited to 'cameltris')
-rwxr-xr-xcameltris/__main__.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/cameltris/__main__.py b/cameltris/__main__.py
index a3333c5..f007cca 100755
--- a/cameltris/__main__.py
+++ b/cameltris/__main__.py
@@ -13,22 +13,29 @@ from .screens.pause import Pause as PauseScreen
from .misc import Pause, UnPause
-def main(args: dict):
- """ Main function to be called with option arguments already parsed """
+def main() -> None:
+ """ Main entry point. """
+ parser = argparse.ArgumentParser()
+
+ parser.add_argument("--starting-level", type=int, choices=list(range(1, 30)), default=1)
+ parser.add_argument("--joystick", type=int, dest="joystick_id", metavar="Joystick ID")
+
+ args = parser.parse_args()
+
pygame.init()
screen = pygame.display.set_mode((801, 1000))
controller: Controller
- if args["joystick_id"] is not None:
- joystick = pygame.joystick.Joystick(args["joystick_id"])
+ if args.joystick_id is not None:
+ joystick = pygame.joystick.Joystick(args.joystick_id)
joystick.init()
controller = JoystickController(joystick)
else:
controller = KeyboardController(pygame.key)
# Just one player
- players = [Player(controller, args["starting_level"])]
+ players = [Player(controller, args.starting_level)]
for player in players:
player.refresh_piece_preview_canvas()
@@ -53,9 +60,4 @@ def main(args: dict):
if __name__ == "__main__":
- PARSER = argparse.ArgumentParser()
-
- PARSER.add_argument("--starting-level", type=int, choices=list(range(1, 30)), default=1)
- PARSER.add_argument("--joystick", type=int, dest="joystick_id", metavar="Joystick ID")
-
- main(vars(PARSER.parse_args()))
+ main()