A 2D game engine written in Python using both SDL2 and PyGame.
Project description
ReForge
A 2D game engine written in Python using both SDL2 and PyGame.
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.0.1.tar.gz
(12.6 kB
view details)
File details
Details for the file reforge-0.0.1.tar.gz
.
File metadata
- Download URL: reforge-0.0.1.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5a53ae4afccbf99e22150801985751f60adc4d830b8e8ede36fe391973de912 |
|
MD5 | 50fcfb82ee1cdcb930311536a38d1f65 |
|
BLAKE2b-256 | e322f6a36337ad26decd40f08faa06f0c3bba6069f5cff8b1b12666736a3f548 |