class hegame.HEGame(HGame)

HEGame is a subclass of HGame for use by games having a level editor. It provides facilities for loading and saving level files, creating level sets and running levels in test mode. It is designed to be used in conjunction with an HEShell.

To use HEGame you need to provide a create_level() method that creates and returns a new level object. If your level object is directly pickleable, that's all you need to do in order to support loading and saving levels. Otherwise you will also have to provide pickle_level() and unpickle_level() methods.

Class Attributes

level_file_version = 1
level_min_version = 1
level_app_version = (1, 0, 0)
level_version_ranges = {}
level_file_magic = "LEVL"
These attributes provide the same information about level files as the corresponding attributes for saved-game files in HGame.

Attributes

level_needs_saving
True when the level has been modified in the level editor and needs to be saved.

Abstract Methods

create_level()
Should create and return a new level object.
pickle_level(pickler, level)
Should preserve the given level object by pickling objects to the given pickler. The default implementation pickles the level object directly.
unpickle_level(unpickler)
Should reconstitute a level by unpickling objects from the given unpickler and return a level object. The default implementation unpickles the level object directly.

Methods

level_changed()
This method should be called by your level editor code whenever the level is modified in such a way as to require saving.
You probably won't have to call the following methods yourself, as they are called when appropriate from HEShell. They are documented here in case you want to know about them for customization purposes.
get_level_path()
Returns the full pathname of the level currently being edited, or None if no level is being edited.
set_level_set_path(path)
Sets the default directory that the user will be taken to next time a level is opened or saved.
set_level_path(path)
Sets the default directory and filename under which the current level will be saved.
get_default_level_set_dir()
Returns the full pathname of the directory containing the level set being edited, or the default custom level directory if no such directory can be determined.
get_default_level_dir()
Returns the full pathname of the directory containing the level being edited, or the default custom levels directory if no such directory can be determined.
mark_current_level_completed()
If the level is not running in test mode, adds it to the list of completed levels.
read_level(path)
Reads a level from the specified file and returns a level object.
write_level(path)
Writes the current level to the specified file.