Engine¶
Contents
Engine¶
-
class
serge.engine.Engine(width=640, height=480, title='Serge', backcolour=(0, 0, 0), icon=None, fullscreen=False)[source]¶ Bases:
serge.common.Loggable,serge.serialize.Serializable,serge.common.EventAwareThe main Serge engine
The engine manages a set of worlds and allows a single Worlds, the current world, to be automatically updated on a certain time frequency.
-
goBackToPreviousWorld(obj=None, arg=None)[source]¶ Return to the world we were in before this one
The arguments are never used and are just here to allow you to use this method as an event callback.
-
removeWorld(world)[source]¶ Remove a world from the engine
Parameters: world – the world instance to remove
-
removeWorldNamed(name)[source]¶ Remove a world with a given name
Parameters: name – the name of the world to remove
-
run(fps, endat=None)[source]¶ Run the updates at the specified frames per second until the optional endtime
Parameters: - fps – the target frames per second (integer)
- endat – a time to stop the engine at (long), eg time.time()+60 to run for a minute
-
runAsync(fps, endat=None)[source]¶ Run the engine asynchronously
Parameters: - fps – the target frames per second (integer)
- endat – a time to stop the engine at (long), eg time.time()+60 to run for a minute
-
save(filename)[source]¶ Store the engine state in a file suitable for loading again in the furture
Parameters: filename – the name of the file to save into
-
setCurrentWorld(world)[source]¶ Set the current world
Parameters: world – the world to set as the current world
-