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.819.tar.gz (4.0 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.819-py3-none-win_amd64.whl (2.1 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3macOS 14.0+ ARM64

goudengine-0.0.819-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.819.tar.gz.

File metadata

  • Download URL: goudengine-0.0.819.tar.gz
  • Upload date:
  • Size: 4.0 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.819.tar.gz
Algorithm Hash digest
SHA256 cfa755af90beb23e2dcce936bd04985ff78e5076b1302481cd00797df3ed0cb5
MD5 a137c6b78b05fe2db0b9d04193cf59db
BLAKE2b-256 b9f31b969fbfa5016d2f7455aa44b71c2eba6cfc059580eb59894d6e5510a149

See more details on using hashes here.

Provenance

The following attestation bundles were made for goudengine-0.0.819.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.819-py3-none-win_amd64.whl.

File metadata

  • Download URL: goudengine-0.0.819-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.819-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 004fdf31ee5d3e9ab703d4148635627b5eef12196c1e755c841426f35abf4a01
MD5 c5f0b2445fb51fd5642efabc7062fbe3
BLAKE2b-256 a1ffc68090ec2dfec0c8a0920efb9d5d8208a9a763b446237f937ae5c65b3f53

See more details on using hashes here.

Provenance

The following attestation bundles were made for goudengine-0.0.819-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.819-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for goudengine-0.0.819-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5bf6d3e91645794308b186669a80eac71548da3fd4f3892d78aa028e3738df77
MD5 f8f4e29a465f71a6eef6f83a7026e7f5
BLAKE2b-256 0f72baa92754116717b6686c097f1bf6df9d9e3ee181f3984280e843d1625708

See more details on using hashes here.

Provenance

The following attestation bundles were made for goudengine-0.0.819-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.819-py3-none-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for goudengine-0.0.819-py3-none-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 493e1cc6f1eaeecc3880e089758f6edde3cc2681b4198ffe26acd29b0f079782
MD5 dd1bdd727eb7ca2df8f1015b01bccca6
BLAKE2b-256 e60373fb53bd13802860e9466603a5641a85df2df765004b502dc7ee3d4048de

See more details on using hashes here.

Provenance

The following attestation bundles were made for goudengine-0.0.819-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.819-py3-none-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for goudengine-0.0.819-py3-none-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 e2d4b598adb642d13ff4c99e95b9e2fce6add956237a655e1c63ab2e7be0c7e0
MD5 3fac95bb2316ac11184250e5df4e2644
BLAKE2b-256 090d31999758cfbd6ee4ae0c31c2adeaa16464d29455abbf603703e90403a7d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for goudengine-0.0.819-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