Skip to main content

Python SDK for GoudEngine - a Rust-powered game engine

Project description

GoudEngine Python SDK

Python bindings for the GoudEngine game engine, providing a Pythonic interface to the Rust core through ctypes FFI.

Design Philosophy

All logic lives in Rust. This SDK is a thin wrapper that marshals data and calls FFI functions. This ensures consistent behavior across all language bindings (C#, Python, Rust native).

Installation

Prerequisites

  1. Build the GoudEngine native library:

    cd goud_engine
    cargo build --release
    
  2. The Python SDK will automatically locate the library in:

    • target/release/libgoud_engine.dylib (macOS)
    • target/release/libgoud_engine.so (Linux)
    • target/release/goud_engine.dll (Windows)

Using the SDK

# Add the SDK to your Python path
import sys
sys.path.insert(0, '/path/to/GoudEngine/sdks/python')

from goud_engine import GoudContext, Transform2D, Sprite, Vec2

Quick Start

Context Management

from goud_engine import GoudContext

# Create a context (manages an ECS world)
ctx = GoudContext.create()

# Spawn entities
entity_id = ctx.spawn_entity()
print(f"Spawned entity: {entity_id}")

# Check entity status
print(f"Entity alive: {ctx.is_entity_alive(entity_id)}")
print(f"Entity count: {ctx.entity_count()}")

# Despawn when done
ctx.despawn_entity(entity_id)

# Clean up
ctx.destroy()

Using Context Manager

from goud_engine import GoudContext

with GoudContext.create() as ctx:
    entity_id = ctx.spawn_entity()
    # Context automatically destroyed when exiting the block

Transform2D Component

import math
from goud_engine import Transform2D, Vec2

# Factory methods (all delegate to Rust FFI)
transform = Transform2D.from_position(100, 50)
transform = Transform2D.from_rotation(math.pi / 4)  # 45 degrees
transform = Transform2D.look_at(0, 0, 100, 100)  # Position looking at target

# Mutation methods (chainable)
transform = Transform2D()
transform.translate(10, 20).rotate(0.5).scale_by(2, 2)

# Direction vectors
forward = transform.forward()  # Returns Vec2
right = transform.right()

# Point transformation
world_point = transform.transform_point(5, 5)  # Local to world
local_point = transform.inverse_transform_point(105, 55)  # World to local

# Interpolation
transform_a = Transform2D.from_position(0, 0)
transform_b = Transform2D.from_position(100, 100)
mid = transform_a.lerp(transform_b, 0.5)  # Midpoint

Sprite Component

from goud_engine import Sprite, Color

# Create a sprite
sprite = Sprite(texture_handle=42)

# Builder pattern (returns new instances)
sprite = (Sprite(texture_handle=42)
    .with_color(1.0, 0.0, 0.0, 1.0)  # Red tint
    .with_flip_x(True)
    .with_anchor(0.5, 1.0)  # Bottom-center
    .with_source_rect(0, 0, 32, 32)  # Sprite sheet
    .with_custom_size(64, 64))  # Scale to 64x64

# Mutable operations (modify in place)
sprite.color = Color.red()
sprite.flip_x = True
sprite.set_source_rect(32, 0, 32, 32)  # Next frame

High-Level Game API

from goud_engine import GoudGame, Transform2D, Sprite

# Create game (placeholder - full implementation coming)
game = GoudGame(800, 600, "My Game")

# Spawn entities
entity = game.spawn()

# Batch spawn
entities = game.spawn_batch(100)

# Clean up
game.close()

API Reference

Types

Type Description
GoudContext Engine context managing an ECS world
GoudResult FFI result type for operations that can fail
GoudEntityId FFI entity identifier
Vec2 2D vector
Color RGBA color
Rect 2D rectangle
Transform2D 2D transformation component
Sprite 2D sprite rendering component
Entity High-level entity wrapper
GoudGame High-level game abstraction

GoudContext Methods

Method Description
create() Creates a new context
destroy() Destroys the context
is_valid() Checks if context is valid
spawn_entity() Spawns an empty entity
spawn_entities(count) Spawns multiple entities
despawn_entity(id) Despawns an entity
is_entity_alive(id) Checks if entity is alive
entity_count() Returns alive entity count

Transform2D Methods

Method Description
from_position(x, y) Factory: position
from_rotation(radians) Factory: rotation
from_scale(sx, sy) Factory: scale
look_at(px, py, tx, ty) Factory: look at target
translate(dx, dy) Translate in world space
translate_local(dx, dy) Translate in local space
rotate(radians) Rotate by angle
scale_by(fx, fy) Multiply scale
forward() Get forward direction
right() Get right direction
transform_point(x, y) Local to world
inverse_transform_point(x, y) World to local
lerp(other, t) Interpolate

Sprite Methods

Method Description
with_color(r, g, b, a) Builder: color tint
with_flip_x(flip) Builder: horizontal flip
with_flip_y(flip) Builder: vertical flip
with_anchor(x, y) Builder: anchor point
with_source_rect(x, y, w, h) Builder: sprite sheet rect
with_custom_size(w, h) Builder: render size
set_source_rect(...) Mutate source rect
clear_source_rect() Clear source rect
set_custom_size(...) Mutate size
clear_custom_size() Clear size

Error Handling

from goud_engine import GoudContext, GoudEngineError

try:
    ctx = GoudContext.create()
    # ... operations
except GoudEngineError as e:
    print(f"Engine error: {e}")

Thread Safety

  • Context creation/destruction is thread-safe
  • Individual contexts are NOT thread-safe
  • Use one context per thread, or synchronize access

Building from Source

# Build the native library
cd goud_engine
cargo build --release

# The Python SDK automatically finds the library in target/release/

License

MIT License - same as GoudEngine core.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goudengine-0.0.818.tar.gz (4.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

goudengine-0.0.818-py3-none-win_amd64.whl (2.1 MB view details)

Uploaded Python 3Windows x86-64

goudengine-0.0.818-py3-none-macosx_14_0_arm64.whl (3.3 MB view details)

Uploaded Python 3macOS 14.0+ ARM64

goudengine-0.0.818-py3-none-macosx_13_0_x86_64.whl (1.1 MB view details)

Uploaded Python 3macOS 13.0+ x86-64

File details

Details for the file goudengine-0.0.818.tar.gz.

File metadata

  • Download URL: goudengine-0.0.818.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for goudengine-0.0.818.tar.gz
Algorithm Hash digest
SHA256 81b096b63203e8dd93fb2045245bddbaf290b0a4a5bfd7b481f6803dec876e25
MD5 66df3bb67161b6f769f7d615a16eb029
BLAKE2b-256 2243c83af65732b8d0fe8e5b0b0df5e3c7e7701f83124a0aaae75ac112b91d97

See more details on using hashes here.

Provenance

The following attestation bundles were made for goudengine-0.0.818.tar.gz:

Publisher: release.yml on aram-devdocs/GoudEngine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file goudengine-0.0.818-py3-none-win_amd64.whl.

File metadata

  • Download URL: goudengine-0.0.818-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for goudengine-0.0.818-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 96f01205c5f7841083bfab5feb168e68e45343c2352c095f3174eefdb2bfc984
MD5 52b368eaaa463e9d797a8f7a6376ccae
BLAKE2b-256 78045a7c4dc18a2e88922148bd6d6072eb606e64194e6e50ddc544cea2e89446

See more details on using hashes here.

Provenance

The following attestation bundles were made for goudengine-0.0.818-py3-none-win_amd64.whl:

Publisher: release.yml on aram-devdocs/GoudEngine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file goudengine-0.0.818-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for goudengine-0.0.818-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fff948a3e29a8d89358a351cb02b7f5e68c684632c88a2f55029769107cbb322
MD5 1897c2f58e54634bc02cfbcd0b9be489
BLAKE2b-256 9fdb446ec912954b25ecb2cb81009d5dae9242e14c98e50ba26fa60ea80c193b

See more details on using hashes here.

Provenance

The following attestation bundles were made for goudengine-0.0.818-py3-none-manylinux2014_x86_64.whl:

Publisher: release.yml on aram-devdocs/GoudEngine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file goudengine-0.0.818-py3-none-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for goudengine-0.0.818-py3-none-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 5adb71d516d406ad091cf4ffe932718474b25f5075b6af8b84df7f143844e417
MD5 b9d496d5e15d0de136c60b6fab1a7bf2
BLAKE2b-256 b3db434cc82886c425be11c1eef22e31a81f6a2db43cd2c9362ef9bbc1d7e6b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for goudengine-0.0.818-py3-none-macosx_14_0_arm64.whl:

Publisher: release.yml on aram-devdocs/GoudEngine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file goudengine-0.0.818-py3-none-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for goudengine-0.0.818-py3-none-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 1fd932448dc28aca55fe3eeaae70aa2a5f152110ea0c2456f3069764a6fb1a9a
MD5 07fad97935e3b255db669d57fce7da5e
BLAKE2b-256 6dc0ee4b57dcaa70c41556d895bab977974edfb800a0c03b9e07928014c9970b

See more details on using hashes here.

Provenance

The following attestation bundles were made for goudengine-0.0.818-py3-none-macosx_13_0_x86_64.whl:

Publisher: release.yml on aram-devdocs/GoudEngine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page