main

Main application module and entry point for the Pyrite graphics engine.

This module contains the core Pyrite class which orchestrates the entire application. It manages the OS-level Pygame window, establishes the ModernGL hardware context, controls the primary execution loop, and routes inputs to the active game state.

class main.Pyrite[source]

Bases: object

The core engine application class. Manages the Pygame window, ModernGL context, main game loop, and dispatches rendering and logic to the active game state (e.g., Menus vs In-Game).

load_config()[source]

Reads and applies engine settings from a local JSON configuration file.

Return type:

None

save_config()[source]

Serializes and saves the active engine configuration to disk.

Return type:

None

on_init()[source]

Instantiates critical subsystems including UI menus, Shader programs, Sound mixers, Textures, and the Player entity.

Return type:

None

init_game_session(save_name='Default_World', force_seed=None, game_mode=None)[source]

Initializes a designated world session, seeding the procedural generator and executing a blocking load loop until the initial area is fully generated and prepared for rendering.

Parameters:
  • save_name (str)

  • force_seed (int | None)

  • game_mode (int | None)

Return type:

None

render_loading_screen(text='INITIALIZING...')[source]

Renders a minimal UI overlay during heavily blocking load operations, ensuring Pygame’s event queue is flushed so the operating system doesn’t flag the application as “Not Responding”.

Parameters:

text (str)

Return type:

None

update()[source]

Advances the central engine logic. Delegates to the active game state (e.g., ticking the world simulation, evaluating UI animations).

Return type:

None

render()[source]

Clears the OpenGL framebuffer and issues draw instructions corresponding to the active state, layering menus over 3D scenes when appropriate.

Return type:

None

handle_events()[source]

Polls raw input events from the operating system and routes them to the respective handlers (e.g., player movement, UI button clicks, or screen toggles).

Return type:

None

quit_game()[source]

Interrupts the primary application execution loop to safely shut down.

Return type:

None

run()[source]

The primary execution loop tracking logic updates, event polling, and frame rendering until the application halts.

Return type:

None