Skip to content

Program132/TextGameEngine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TextGameEngine

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.


Features

  • 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.

Requirements

  • Python 3.13+
  • Virtual environment recommended.
  • Install dependencies:
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt

Dependencies include:

  • PyAutoGUI
  • pyfiglet
  • pynput
  • simpleaudio
  • pyinstaller
  • PyScreeze, PyRect, PyMsgBox, PyGetWindow, altgraph, evdev, etc.

Running the Engine

Activate your virtual environment:

source env/bin/activate
python main.py

Compiling a Standalone Executable (Linux)

To package the engine as a single binary using PyInstaller:

  1. Clean previous builds:
rm -rf build dist main.spec
  1. Create a PyInstaller hook for pyfiglet fonts:
mkdir -p hooks
nano hooks/hook-pyfiglet.py

Paste 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.

  1. Build the executable:
pyinstaller --onefile main.py --clean --additional-hooks-dir=hooks -v

Flags:

  • --onefile → generate a single executable in dist/.
  • --clean → clears PyInstaller cache.
  • --additional-hooks-dir → include pyfiglet fonts.
  • -v → verbose mode for debugging.
  1. Run the executable:
cd dist
./main

Examples

The examples/ folder contains small scripts demonstrating engine features:

  • Drawing shapes
  • Handling events
  • UI and menus
  • Animations and sounds
  • Multi-level games

Notes

  • 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.

About

2D Game Engine text-based

Resources

Stars

Watchers

Forks

Languages