class provides a framework for defining and parsing command line
options. It also predefines certain options used by Humerus and works
together with the HShell and HEShell
classes to handle them transparently. You can either use this class
as-is, or subclass it to override options and add new options of your
The standard command-line options supported by the Options class are:
have control over the default values of these options, as well as
whether the user is allowed to change them. By default, the only
options that are enabled are the New Game, Enter Editor (if your game has one) and Filename options. To
enable the other options, you will have to set the appropriate xxx_option_allowed flags in your Options subclass.
- Fullscreen/Windowed - whether to start the game in fullscreen or windowed mode.
- Screen size - allows the user to override the default screen size.
- Frame rate - allows the user to specify the number of frames per second for animated games.
- New game - allows the user to start a new game immediately instead of going through the main menu screen.
- Enter editor - allows the user to enter the level editor immediately instead of going through the main menu screen.
- a file name may be provided on the command line, interpreted as a
saved-game file to restore, a level to load or a level set to play.
- display_flags = 0
- Flags to be passed to the PyGame set_display_mode() function. (The FULLSCREEN flag will automatically be added if appopriate.)
- fullscreen_by_default = False
- Whether to start the game in fullscreen mode by default.
- screen_size_option = (800, 600)
- The default screen size to use.
- frame_rate_option = 0
- Default number of frames per second. If this is 0, the frame timer will not be set and no begin_frame() calls will be made. If your game needs frame timing, you will have to set this to an appropriate default value.
- allow_fullscreen_option = False
- User can force the game to run in fullscreen mode using the -f option.
- allow_windowed_option = False
- User can force the game to run in windowed mode using the -w option.
- allow_screen_size_option = False
- User can specify a screen size using the -s option.
- allow_frame_rate_option = False
- User can specify a frame rate using the -F option.
- allow_new_game_option = True
- User can start a new game using the -n option.
- User can enter the level editor using the -e option.
- std_command_line_options = [
- ("-f,--fullscreen", 'fullscreen', "Run in full-screen mode" ),
("-w,--windowed", 'windowed', "Run in
- ("-s,--size", 'screen_size', "Window size: <width>x<height>", str),
- ("-F,--framerate", 'frame_rate', "Frames per second", int),
("-n,--newgame", 'new_game', "Start
for the standard command line options. The first item in each
descriptor defines the short and long forms of the command line flag.
The second item with '_option' appended names an attribute in the Options object that will be set to the value of the option. The
third item is the help text for the option. The fourth item (optional)
specifies the option's type; if omitted, the option is a boolean.
- extra_command_line_options = 
- You can add descriptors here for any additional command line options you want.
- debug_command_line_options = 
- You can add descriptors here for debugging-related command line options. They will only be active when the environment variable DEBUG has a true value.
AttributesThe following attributes are filled in with the values resulting from parsing the command line options.
- True if the -f flag was given.
- True if the -w option was given.
- Screen size, either user-specified or default.
- Frame rate, either user-specified or default.
- True if the -n flag was given.
- The first non-option argument from the command line, if any.
- Options(with_editor = False)
- Instantiating the Options class causes the following to occur:
line arguments are parsed. Values of command line options are stored in
attributes of the Options instance as specified by their descriptors.
- The PyGame screen is initialized with parameters determined from the default option values and settings specified by the user.
- If the frame rate default or user-specified value is nonzero, the frame timer is started.
Editing-related command line options are only enabled if with_editor is true.