Engine
Engine
Engine(
name: str,
pipeline: Pipeline,
*,
size: IntVector2 = None,
display: int = 0,
icon: pygame.Surface = None,
settings_persistent: bool = True,
debug: bool = False
)
Game Engine
Instantiates a game engine that handles all backend code for running games.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name of the engine window.
TYPE:
|
pipeline
|
The pipeline library the engine should use.
TYPE:
|
size
|
The X and Y sizes for the game window - If
TYPE:
|
display
|
The index of the display/monitor for the rendering screen.
TYPE:
|
icon
|
The image/surface of the game window icon. |
settings_persistent
|
If the engine should read and write the internal
TYPE:
|
debug
|
If the debug mode should be enabled - Allows debug logs to be shown.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
|
TypeError:
|
If the provided |
settings
instance-attribute
The settings that the engine renders/runs the game with
quit
quit() -> None
Stops the engine and cleans up.
register_scene
Register a scene to the engine.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The unique name used to lookup and manipulate this scene.
TYPE:
|
scene
|
The scene to register.
TYPE:
|
overwrite
|
If the unique name is already used, overwrite it, else throw an error.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If the unique name already exists and overwriting is not enabled. |
TypeError
|
|
register_scenes
Register a set of scenes to the engine.
| PARAMETER | DESCRIPTION |
|---|---|
scenes
|
The name-scene pairs to register. |
overwrite
|
If any unique name is already used, overwrite it, else throw an error.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If any unique name already exists and overwriting is not enabled. |
TypeError
|
|
register_scenes_from_folder
Register all Scene objects within all files in a folder to the engine.
| PARAMETER | DESCRIPTION |
|---|---|
folder
|
The folder to register scenes from.
TYPE:
|
overwrite
|
If any unique name is already used, overwrite it, else throw an error.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
|
TypeError
|
|
Tip
If you plan on bundling this game into an executable file: Continue to use this method, but also include the raw scene program files in the folder provided as well as the .exe file OR manually register each scene. This is because to bundle Python into executable files, there must be a direct reference to dependencies. Hotloading scenes has no direct reference.
Note
Folder must be in the same directory as your project. The engine will only walk through the files in this folder, not any subdirectories. All unique scene names will be generated from the Scene subclass names themselves:
class MyScene(wame.Scene):
...
class MainMenuScene(wame.Scene):
...
And so forth...
set_background
set_background(color: ColorRGB) -> None
set_game_loop_enabled
set_game_loop_enabled(enabled: bool) -> None
Set the engine to continuously run the game loop or poll it manually using .step_game_loop.
| PARAMETER | DESCRIPTION |
|---|---|
enabled
|
If the game loop should continuously run.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the provided value is not a |
Warning
If disabled, this will disable the fixed update functionality of the Engine and Scene objects.
set_mouse_visible
set_mouse_visible(state: bool = True) -> None
set_mouse_locked
set_mouse_locked(state: bool = False) -> None
set_pipeline
set_pipeline(pipeline: Pipeline) -> None
Set the rendering pipeline that the engine should use.
| PARAMETER | DESCRIPTION |
|---|---|
pipeline
|
The rendering pipeline to switch to.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If the pipeline tries to switch during runtime. |
TypeError
|
If the provided pipeline isn't a |
set_scene
set_scene(name: str, *args, **kwargs) -> None
Switch the engine to another scene and clean up the previous (if any).
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The unique name of the scene to switch to (must be previously registered).
TYPE:
|
args
|
Any data you wish to pass to the scene instance.
TYPE:
|
kwargs
|
Any data you wish to pass to the scene instance. |
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
|
TypeError
|
If the provided name is not a |
set_update_interval
set_update_interval(interval: Interval) -> None
start
start() -> None
Starts the engine.
Warning
This is a blocking call. No code below will execute until the engine has stopped running.
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If the engine is started without a scene registered and set. |
step_game_loop
step_game_loop() -> None
Poll the game loop to run a cycle (update/render) - Only use when game loop is disabled with .set_game_loop_enabled(False).