Fix package structure and entry point
This commit is contained in:
1 parent
0571392afe
commit
31e9771ba0
3 files changed
+6
-5
No files matched your search
+3
-1
@@ -13,6 +13,7 @@ from src.game import Game, GameState
|
||||
from src.snake import Snake, Direction
|
||||
from src.food import Food
|
||||
from src.menu import Menu, GameMode, MenuItem
|
||||
from src.cli import main as cli_main
|
||||
|
||||
__version__ = '0.1.0'
|
||||
__author__ = 'Rbanh'
|
||||
@@ -26,5 +27,6 @@ __all__ = [
|
||||
'Food',
|
||||
'Menu',
|
||||
'GameMode',
|
||||
'MenuItem'
|
||||
'MenuItem',
|
||||
'cli_main'
|
||||
]
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
"""
|
||||
AI Snake Game CLI
|
||||
|
||||
This module provides the command-line interface for running the AI Snake Game.
|
||||
It handles command-line arguments for different game modes and configurations.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
from src import Game, GameMode
|
||||
|
||||
def main():
|
||||
"""
|
||||
Main entry point for the AI Snake Game.
|
||||
|
||||
Parses command line arguments and initializes the game with the specified settings.
|
||||
Available modes:
|
||||
- Normal mode: Standard game settings
|
||||
- Test mode: Smaller window and faster speed
|
||||
- Debug mode: Shows grid and additional debug information
|
||||
"""
|
||||
parser = argparse.ArgumentParser(description='Run AI Snake Game')
|
||||
parser.add_argument('--test', action='store_true',
|
||||
help='Run game in test mode (smaller window, faster speed)')
|
||||
parser.add_argument('--debug', action='store_true',
|
||||
help='Run game in debug mode (shows grid and additional info)')
|
||||
parser.add_argument('--ai-only', action='store_true',
|
||||
help='Start directly in AI mode (skips menu)')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Create game instance
|
||||
game = Game()
|
||||
|
||||
# Apply test mode settings
|
||||
if args.test:
|
||||
game.width = 400
|
||||
game.height = 300
|
||||
game.block_size = 20
|
||||
game.fps = 30
|
||||
|
||||
# Apply debug mode settings
|
||||
if args.debug:
|
||||
game.debug = True
|
||||
|
||||
# Run the game
|
||||
try:
|
||||
game.run()
|
||||
except KeyboardInterrupt:
|
||||
print("\nGame terminated by user")
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
finally:
|
||||
# Clean up will be handled by Game class destructor
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user