KodEngine.engine package¶
Submodules¶
KodEngine.engine.ErrorHandler module¶
- class KodEngine.engine.ErrorHandler.ErrorHandler[source]¶
Bases:
objectCentralized error and status message dispatcher for the engine.
The handler can either forward messages directly to an editor console callback or queue them while editor mode is enabled but no callback is attached yet.
- COLORS = {'ERROR': (255, 50, 50), 'INFO': (200, 200, 200), 'SUCCESS': (50, 255, 100), 'WARNING': (255, 200, 50)}¶
- classmethod clear_console_callback()[source]¶
Detach the editor console callback and disable editor mode.
- classmethod is_editor_mode() bool[source]¶
Return whether the handler is currently buffering editor output.
Returns¶
- bool
Truewhen editor mode is enabled, otherwiseFalse.
- classmethod set_console_callback(callback: Callable[[str, str], None])[source]¶
Register the editor console callback used for log output.
Parameters¶
- callback:
Callable that receives the message type and formatted message. Any messages queued while editor mode was active are flushed to this callback immediately.
KodEngine.engine.ExportingServer module¶
- class KodEngine.engine.ExportingServer.Exporter(project_dir: str, project_settings: dict[str, Any])[source]¶
Bases:
objectPackage a project into a distributable build.
KodEngine.engine.Globals module¶
KodEngine.engine.Kod module¶
- class KodEngine.engine.Kod.App(_configuration: Settings, editor_mode=False)[source]¶
Bases:
objectMain application runner for the engine runtime and editor.
- calculate_delta(last_frame_time)[source]¶
Compute frame delta time from the previous tick timestamp.
- distribute_node_buckets()[source]¶
Split the current scene into rendering, physics, and UI buckets.
Returns¶
- dict[str, list]
Node buckets keyed by
rendering,physics, andui.
- handle_resize(size, persist_project_resolution=True)[source]¶
Update the runtime viewport and optionally persist it to settings.
Parameters¶
- size:
New window size.
- persist_project_resolution:
When
True, store the updated size in project settings.
KodEngine.engine.Nodes module¶
- class KodEngine.engine.Nodes.AnimatedSprite2D[source]¶
Bases:
Sprite2DSprite node that advances through a resource-backed animation.
- add_animation(animation: SpriteAnimation)[source]¶
Register an animation resource on the sprite.
- property current_animation¶
- property image¶
Return the current animation frame as a surface.
- class KodEngine.engine.Nodes.Area2D[source]¶
Bases:
CollisionObject2DCollision area node that tracks overlapping bodies and areas.
- get_overlapping_bodies() list[CollisionObject2D][source]¶
Return bodies currently overlapping the area.
- class KodEngine.engine.Nodes.AudioPlayer[source]¶
Bases:
NodeNode that plays an audio resource through pygame mixer.
- property audio¶
- property volume¶
- class KodEngine.engine.Nodes.CollisionObject2D[source]¶
Bases:
Node2D,ABCBase node for 2D collision bodies and areas.
- class KodEngine.engine.Nodes.CollisionShape2D[source]¶
Bases:
Node2D,ABCBase node for collision shape components.
- class KodEngine.engine.Nodes.Control[source]¶
Bases:
NodeBase UI node with anchoring, layout, and font settings.
- class AnchorType(*values)[source]¶
Bases:
Enum- BOTTOM_CENTER = 'BOTTOM_CENTER'¶
- BOTTOM_LEFT = 'BOTTOM_LEFT'¶
- BOTTOM_RIGHT = 'BOTTOM_RIGHT'¶
- CENTER = 'CENTER'¶
- CENTER_LEFT = 'CENTER_LEFT'¶
- CENTER_RIGHT = 'CENTER_RIGHT'¶
- FULL_RECT = 'FULL_RECT'¶
- NONE = 'NONE'¶
- TOP_CENTER = 'TOP_CENTER'¶
- TOP_LEFT = 'TOP_LEFT'¶
- TOP_RIGHT = 'TOP_RIGHT'¶
- DEFAULT_BG_COLOR = (58, 62, 72, 255)¶
- DEFAULT_FONT_COLOR = (245, 245, 245, 255)¶
- DEFAULT_FONT_SIZE = 14¶
- DEFAULT_GAP = 4¶
- DEFAULT_PADDING = (4, 4, 4, 4)¶
- property global_position¶
Return the control’s global position including anchor offset.
- class KodEngine.engine.Nodes.DynamicBody2D[source]¶
Bases:
CollisionObject2DPhysics body that integrates velocity each frame.
- class KodEngine.engine.Nodes.HBoxContainer[source]¶
Bases:
ControlHorizontal container that stacks child controls.
- class KodEngine.engine.Nodes.KinematicBody2D[source]¶
Bases:
CollisionObject2DCollision body that moves explicitly via script or solver.
- class KodEngine.engine.Nodes.Label[source]¶
Bases:
ControlText label control.
- class KodEngine.engine.Nodes.Node[source]¶
Bases:
objectBase node for the engine scene tree.
- change_scene_to(scene_path)[source]¶
Load a scene and make it the active scene.
Parameters¶
- scene_path:
Path to the scene file.
Returns¶
- bool
Truewhen the scene switch succeeds.
- connect(signal, callback=None, target=None, method=None, oneshot=False, allow_duplicate=False)[source]¶
Connect a signal to a callback or method.
Parameters¶
- signal:
Signal name to connect.
- callback:
Callable or method name to invoke.
- target:
Optional explicit target object for method callbacks.
- method:
Optional method name override.
- oneshot:
When
True, remove the connection after the first emit.- allow_duplicate:
When
True, permit duplicate connections.
Returns¶
- int | None
Connection id when successful, otherwise
None.
- disconnect(connection_id: int)[source]¶
Remove a signal connection by id.
Returns¶
- bool
Truewhen the connection was removed.
- disconnect_signal(signal, callback=None, target=None, method=None)[source]¶
Remove all matching connections for a signal.
Returns¶
- int
Number of removed connections.
- emit_signal(signal, *args, **kwargs)[source]¶
Emit a signal and invoke all matching connections.
Returns¶
- int
Number of callbacks that were successfully called.
- get_signal_connections(signal=None)[source]¶
Return signal connection metadata.
Parameters¶
- signal:
Optional signal name to filter by.
Returns¶
- list | dict
Connections for one signal or all connections grouped by signal.
- quit()[source]¶
Request application shutdown.
Returns¶
- bool
Truewhen an active app was found and marked for exit.
- runtime_script: object | None¶
- property script¶
- class KodEngine.engine.Nodes.Node2D[source]¶
Bases:
NodeBase node type with 2D transform state.
- property global_position¶
- property global_rotation: float¶
- property global_scale¶
- property global_visible: bool¶
- position: tuple[float, float]¶
- rotation: float¶
- scale: tuple[float, float]¶
- class KodEngine.engine.Nodes.RectangleCollisionShape2D[source]¶
Bases:
CollisionShape2DAxis-aligned rectangle collision shape node.
- class KodEngine.engine.Nodes.Sprite2D[source]¶
Bases:
Node2DRenderable 2D sprite node.
- property image¶
Return the rendered sprite surface or
None.
- property texture¶
- class KodEngine.engine.Nodes.StaticBody2D[source]¶
Bases:
CollisionObject2DNon-moving collision body.
- class KodEngine.engine.Nodes.TextureProgress[source]¶
Bases:
ControlProgress bar control with separate background and fill textures.
- property fill_texture¶
Return the fill texture resource.
- property under_texture¶
Return the background texture resource.
- class KodEngine.engine.Nodes.TextureRect2D[source]¶
Bases:
ControlUI control that displays a texture resource.
- property image¶
Return the loaded texture surface or
None.
- property texture¶
- class KodEngine.engine.Nodes.TileMap2D[source]¶
Bases:
Node2DNode that stores and renders layered tile data.
- property bounds¶
Return the tilemap bounds in tile coordinates.
- property chunk_size¶
- get_tile_id(tile_pos: tuple[int, int], layer: int = 0) int[source]¶
Return the tile id at a coordinate for the requested layer.
- set_bounds(bounds, preserve: bool = True, fill_value: int = -1)[source]¶
Resize the tilemap bounds, optionally preserving existing tiles.
- set_tile_id(tile_pos: tuple[int, int], tile_id: int, layer: int = 0)[source]¶
Set a tile id and grow the tilemap bounds when needed.
Returns¶
- bool
Always returns
Trueafter the tile is written.
- shrink_to_fit(fill_value: int = -1)[source]¶
Trim tile bounds to the smallest rectangle that contains tiles.
- property tile_layers¶
Return the internal tile layer mapping.
- tile_to_world(tile_pos: tuple[int, int]) tuple[int, int][source]¶
Convert tile coordinates into world coordinates.
- property tileset¶
Return the active tileset resource.
- property world_bounds: tuple[tuple[int, int], tuple[int, int]]¶
Return world-space bounds for the tilemap.
KodEngine.engine.PhysicsServer module¶
- class KodEngine.engine.PhysicsServer.PhysicsSolver2D(configuration)[source]¶
Bases:
object- check_collision_pair(body1, shape1, body2, shape2)[source]¶
Return whether two rectangle collision shapes overlap.
KodEngine.engine.RenderingServer module¶
- class KodEngine.engine.RenderingServer.Renderer2D(_configuration, _pygame, _screen, _debug_renderer=None)[source]¶
Bases:
object2D renderer responsible for world and UI drawing.
- create_node_structure(node, nodes_array=None)[source]¶
Collect renderable nodes from a subtree into a flat list.
Parameters¶
- node:
Root node to traverse.
- nodes_array:
Existing list to append to.
Returns¶
- list
Flat list of renderable nodes.
- is_inside_viewport(object, camera, project_settings)[source]¶
Return whether a sprite-like object intersects the camera frustum.
- is_tile_inside_viewport(tile_world_x, tile_world_y, tile_width, tile_height, camera, project_settings)[source]¶
Return whether a tile rectangle intersects the camera frustum.
- render_frame(scene, _camera, renderable_nodes, physics_nodes=None)[source]¶
Render a world frame, including optional collision debug overlays.
KodEngine.engine.ResourceServer module¶
- class KodEngine.engine.ResourceServer.ResourceLoader[source]¶
Bases:
objectLoad, resolve, and cache resource files for the engine.
- static load(path: str)[source]¶
Load a resource from disk and cache the loaded instance.
Parameters¶
- path:
Path to the resource file.
Returns¶
- object | None
Loaded resource instance, or
Nonewhen the file cannot be resolved or decoded.
- class KodEngine.engine.ResourceServer.SceneLoader[source]¶
Bases:
objectSerialize and deserialize scene trees to the on-disk JSON format.
- RESOURCE_KEY = '__resource__'¶
- json = <module 'json' from '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/__init__.py'>¶
- static load(file_path)[source]¶
Load a scene from a JSON file.
Parameters¶
- file_path:
Scene file to load.
Returns¶
- Scene | Node | None
Loaded scene object, root node, or
Noneon failure.
KodEngine.engine.Resources module¶
- class KodEngine.engine.Resources.AudioStream(name: str = 'Audio', resource_path: str | None = None)[source]¶
Bases:
ResourceAudio resource backed by a pygame mixer sound object.
- extensions: tuple[str, ...] = ('.mp3', '.wav', '.ogg')¶
- type_id = 'AudioStream'¶
- class KodEngine.engine.Resources.CollisionRectangleShape(size: tuple[float, float] = (32, 32), resource_path: str | None = None)[source]¶
Bases:
CollisionShapeAxis-aligned rectangle collision shape resource.
- classmethod from_dict(data: dict)[source]¶
Deserialize a rectangle collision shape from a dictionary.
- type_id = 'CollisionRectangleShape'¶
- class KodEngine.engine.Resources.CollisionShape(name='CollisionShape', resource_path=None)[source]¶
Bases:
ResourceBase resource for collision shape definitions.
- type_id = 'CollisionShape'¶
- class KodEngine.engine.Resources.Font(name='Font', size: int = 14, resource_path: str | None = None)[source]¶
Bases:
ResourceFont resource used by UI rendering.
- color: tuple[int, int, int, int]¶
- extensions: tuple[str, ...] = ('.font', '.json')¶
- size: int¶
- type_id = 'Font'¶
- class KodEngine.engine.Resources.Resource(name: str = 'Resource', resource_path: str | None = None)[source]¶
Bases:
objectBase serializable resource type used by the engine.
- classmethod class_for_extension(extension: str)[source]¶
Look up a registered resource class for a file extension.
- classmethod class_for_type(type_name: str)[source]¶
Look up a registered resource class for a serialized type name.
- extensions: tuple[str, ...] = ()¶
- classmethod from_dict(data: dict)[source]¶
Deserialize a resource from a dictionary payload.
Parameters¶
- data:
Serialized resource data.
Returns¶
- Resource | None
Deserialized resource instance, or
Nonefor invalid input.
- type_id = 'Resource'¶
- class KodEngine.engine.Resources.Script(name='Script', resource_path: str | None = None)[source]¶
Bases:
ResourceResource describing a Python script attached to a node.
- extensions: tuple[str, ...] = ('.py',)¶
- type_id = 'Script'¶
- class KodEngine.engine.Resources.ScriptProxy(node, script_path: str)[source]¶
Bases:
objectLightweight wrapper that forwards runtime callbacks into a module.
- class KodEngine.engine.Resources.SpriteAnimation(name='Animation', spritesheet=None, frame_size: tuple[int, int] = (0, 0), frames: int = 0, _loop: bool = True, fps: int = 12, resource_path: str | None = None)[source]¶
Bases:
ResourceAnimation resource that slices frames from a sprite sheet.
- extensions: tuple[str, ...] = ('.anim', '.json')¶
- frame_regions: list[tuple[tuple[int, int], tuple[int, int]]]¶
- classmethod from_dict(data: dict)[source]¶
Deserialize an animation resource from a dictionary payload.
- type_id = 'SpriteAnimation'¶
- class KodEngine.engine.Resources.Texture2D(name='Texture', resource_path: str | None = None)[source]¶
Bases:
ResourceImage resource that loads textures with alpha support.
- extensions: tuple[str, ...] = ('.png', '.jpg', '.jpeg', '.bmp')¶
- classmethod from_dict(data: dict)[source]¶
Deserialize a texture resource from a dictionary payload.
- type_id = 'Texture2D'¶
- class KodEngine.engine.Resources.Tile2D(id: int, name='Tile', resource_path: str | None = None)[source]¶
Bases:
ResourceIndividual tile definition stored inside a tileset.
- collision_shape: CollisionShape | None¶
- texture_region: tuple[tuple[int, int], tuple[int, int]]¶
- type_id = 'Tile'¶
- class KodEngine.engine.Resources.Tileset2D(name='Tileset', resource_path: str | None = None)[source]¶
Bases:
ResourceTileset resource used by
TileMap2Dnodes.- add_tile(tile=None)[source]¶
Add a tile to the tileset and return it.
Parameters¶
- tile:
Optional tile instance to append. When omitted, a default tile is created automatically.
Returns¶
- Tile2D | None
Added tile, or
Nonewhen the input is invalid.
- extensions: tuple[str, ...] = ('.tileset', '.json')¶
- classmethod from_dict(data: dict)[source]¶
Deserialize a tileset resource from a dictionary payload.
- type_id = 'Tileset'¶