Skip to main content

A Unity-like 3D engine in Python using pygame

Project description

GamEngine3D is a Python 3D engine for creating interactive 3D scenes. This README focuses on basic usage.

Quick Start

from gamengine3d import *

# 1. Initialize the engine
engine = Engine(1200, 800, background_color=Color.light_blue)

# 2. Create objects
floor = Cuboid(size=vector3d(5, 0.1, 5), color=Color.light_grey, name="Floor")
player = Cuboid(name="Player", color=Color.light_red, size=vector3d(0.2), pos=vector3d(0, 1))

# 3. Add objects to the engine
engine.add_object(floor)
engine.add_object(player)

# 4. Attach behavior to objects
player.attach("player_controller.py", engine.context)

# 5. Run the engine
engine.run(dynamic_view=True)

Notes

Engine: Manages rendering, lights, and the main loop.

Objects: Add cubes, spheres, or custom shapes with Cuboid(), Sphere(), etc.

Attach Scripts: Use .attach("script.py", context) to add movement, input, or custom logic.

Run: engine.run() starts the simulation; dynamic_view=True enables interactive camera movement.

Example: player_controller.py

from gamengine3d import *
import math

class PlayerController:
    def __init__(self, obj, context):
        self.obj = obj
        self.context = context
        self.speed = 1
        self.context.on_key_held("up", callback=self.move_forward, dt=True)

    def update(self, dt):
        pass  # called every frame

    def move_forward(self, dt):
        # simple forward movement
        yaw = math.radians(self.obj.rotation.z)
        forward = vector3d(-math.sin(yaw), 0, math.cos(yaw))
        self.obj.pos += forward * self.speed * dt

This minimal PlayerController shows how to attach a script to an object and respond to input.

You can run any built-in demo with gamengine3d demo <demo_name> and see all available options using gamengine3d demo -h.

The 2d version of gamengine3d is out under gamengine2d

Check out the full documentation for this package here: Package Docs

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

gamengine3d-1.15.1.tar.gz (86.7 kB view details)

Uploaded Source

Built Distribution

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

gamengine3d-1.15.1-py3-none-any.whl (94.2 kB view details)

Uploaded Python 3

File details

Details for the file gamengine3d-1.15.1.tar.gz.

File metadata

  • Download URL: gamengine3d-1.15.1.tar.gz
  • Upload date:
  • Size: 86.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for gamengine3d-1.15.1.tar.gz
Algorithm Hash digest
SHA256 40281f7fc4de511d03a86a4e51f3207f73a4bf9941beacdabdc0e15788121762
MD5 a8be2d6b850a6eae4f53c5f70acf698e
BLAKE2b-256 ab224f31474a584b3acf2ab5bea5240778efde1abb75414cb2d9de0845253de0

See more details on using hashes here.

File details

Details for the file gamengine3d-1.15.1-py3-none-any.whl.

File metadata

  • Download URL: gamengine3d-1.15.1-py3-none-any.whl
  • Upload date:
  • Size: 94.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for gamengine3d-1.15.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d6dc1965c3ea3ffca55cae84ab7be08ca31c853724f5327e29e00bacbdd0a14d
MD5 d61bfd2eec17daa8b58f18094682b4d9
BLAKE2b-256 e6243f4a31b6d95e1113134d8c424c3eeac90e75c4ca3714a6b28d44d6d6946c

See more details on using hashes here.

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