A 2D game engine written in Python using both PyGame, PySDL2 and PySDL3.
Project description
ReForge [Forge IV]
A 2D game engine written in Python using both PyGame, PySDL2 and PySDL3.
Getting Started
How to install.
pip install ReForge
Examples
Creating a window.
import os
os.environ["REFORGE_API"] = "sdl2"
import reforge, ctypes
def reforgeEntry(argc: int, argv: reforge.List[str]) -> int:
context = reforge.Context()
context.makeContextCurrent()
window = reforge.Window(title = "ReForge", width = 1200, height = 600)
context.registerWindow(window)
renderer = reforge.Renderer(window)
scene = reforge.Scene()
while not context.isTerminated():
context.pollEvents()
renderer.clear(reforge.Vector4(0.0, 0.0, 0.0, 255.0))
renderer.renderScene(scene)
renderer.present()
context.terminate()
return reforge.exitSuccess
Rendering a rect.
import os
os.environ["REFORGE_API"] = "sdl2"
import reforge, ctypes
def reforgeEntry(argc: int, argv: reforge.List[str]) -> int:
context = reforge.Context()
context.makeContextCurrent()
window = reforge.Window(title = "ReForge", width = 1200, height = 600)
context.registerWindow(window)
renderer = reforge.Renderer(window)
scene = reforge.Scene()
entity = scene.createEntity()
entity.addComponent(reforge.RectComponent(fill = False, color = reforge.Vector4(0.0, 128.0, 128.0, 255.0)))
entity.getComponent(reforge.TransformComponent).scale = reforge.Vector2(200.0, 200.0)
entity.getComponent(reforge.TransformComponent).position = \
window.size / 2.0 - entity.getComponent(reforge.TransformComponent).scale / 2.0
while not context.isTerminated():
context.pollEvents()
renderer.clear(reforge.Vector4(0.0, 0.0, 0.0, 255.0))
renderer.renderScene(scene)
renderer.present()
renderer.terminate()
context.terminate()
return reforge.exitSuccess
Using the low-level API.
import os
os.environ["REFORGE_API"] = "sdl2"
import reforge, ctypes
def reforgeEntry(argc: int, argv: reforge.List[str]) -> int:
context = reforge.api.Context()
window = reforge.api.Window(title = "ReForge", width = 1200, height = 600)
renderer = reforge.api.Renderer(window)
inputHandler = reforge.api.Input(window)
eventHandler = reforge.api.EventHandler()
event = reforge.api.Event()
running = True
while running:
while eventHandler.pollEvents(event):
if event.type == reforge.api.EventType.WindowClosed:
running = False
inputHandler.eventHandler(event)
if inputHandler.keyboard.keys[reforge.api.Key.Escape]:
running = False
renderer.clear(reforge.Vector4(0.0, 0.0, 0.0, 255.0))
renderer.present()
eventHandler.terminate()
inputHandler.terminate()
renderer.terminate()
window.terminate()
context.terminate()
return reforge.exitSuccess
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
reforge-0.1.0.tar.gz
(16.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ReForge-0.1.0-py3-none-any.whl
(29.5 kB
view details)
File details
Details for the file reforge-0.1.0.tar.gz.
File metadata
- Download URL: reforge-0.1.0.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a58a6c9bff5a8687b176bd3e7ca61b2d78e4d10a9495eeba76f8b9794823f4a
|
|
| MD5 |
2d6bd5af65c9078d9489b8a92fd8c065
|
|
| BLAKE2b-256 |
6d262855324c790efd060029298c5013e718365de5fd3f9ce098d61a13a11350
|
File details
Details for the file ReForge-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ReForge-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39ecc43a7256b4b2ab71406fb028bb7b247d8a8b923cbd13e45f0167aa94b4dc
|
|
| MD5 |
30f745ad8cea05db2eae6254af4945ba
|
|
| BLAKE2b-256 |
791052f70ee54ad59dd11d70ac29dfc1e3174f081b59c88e6ebd568780db9a95
|