TextGameEngine is a Python terminal-based game engine designed for ASCII graphics, UI elements, animations, sounds, and keyboard/mouse input. It allows you to create interactive games directly in the terminal.
- Terminal-based ASCII rendering.
- Interactive UI elements: buttons, menus, text.
- Supports animations and sounds.
- Mouse and keyboard input tracking.
- Adaptable to any terminal size.
- Examples included for learning and testing.
- Python 3.13+
- Virtual environment recommended.
- Install dependencies:
python3 -m venv env
source env/bin/activate
pip install -r requirements.txtDependencies include:
PyAutoGUIpyfigletpynputsimpleaudiopyinstallerPyScreeze,PyRect,PyMsgBox,PyGetWindow,altgraph,evdev, etc.
Activate your virtual environment:
source env/bin/activate
python main.pyTo package the engine as a single binary using PyInstaller:
- Clean previous builds:
rm -rf build dist main.spec- Create a PyInstaller hook for pyfiglet fonts:
mkdir -p hooks
nano hooks/hook-pyfiglet.pyPaste the following:
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('pyfiglet', includes=['fonts/*'])This ensures the pyfiglet fonts are included in the binary.
- Build the executable:
pyinstaller --onefile main.py --clean --additional-hooks-dir=hooks -vFlags:
--onefile→ generate a single executable indist/.--clean→ clears PyInstaller cache.--additional-hooks-dir→ include pyfiglet fonts.-v→ verbose mode for debugging.
- Run the executable:
cd dist
./mainThe examples/ folder contains small scripts demonstrating engine features:
- Drawing shapes
- Handling events
- UI and menus
- Animations and sounds
- Multi-level games
- The engine dynamically adapts to terminal size.
- Recommended terminal size for best experience: 236x61
- Virtual environment is recommended for running and developing.
- All builds, caches, and environment folders are excluded via
.gitignore.