Framework for making text-based adventure games (interactive finction)
Project description
text_game_maker is a framework for building simple text-based games. Supports Python 2 and 3 on Linux and Windows (tested on Debian and Windows 10).
Features
Builder API pattern that implements a 2D tile-based grid system for building maps and creating game objects with a few lines of Python.
Flexible object model for defining game objects and NPCs. Many useful game objects and behaviours are pre-defined so you can start making a game straight away, but these classes are easy to extend if you need to implement your own custom game objects.
NPCs that you can actually speak to, like a chatbot. text_game_maker NPCs allow you to define custom responses and contexts for discussions using regular expressions, so you can build an NPC which responds with some contextual awareness like a chatbot.
Arbitrary saving/loading of game states. All game objects can be serialized to, or loaded from, JSON data.
Flexible and extensible parser. The parser that handles game input already has a lot of useful commands and behaviours built-in. However, any of the built-in commands can be disabled if necessary, and the parser provides methods that allow new commands to be defined.
Configurable input/output streams. text_game_maker allows custom handlers to be set for handling user input, and for displaying game output. By default, text_game_maker will use a prompt-toolkit session that interacts with stdin and stdout of the process it is running in. Defining custom input/output handlers allows you to run your game, for example, as a slack bot instead (see scripts/text-game-slackbot-runner.py).
text_game_maker has a music system that allows polyphonic music (not fancy, just simple tones that sound like an old Nokia ringtone, but with full polyphony) to be written as simple text files that can be loaded and played during the game (see PTTTL). pygame is used for playback of the raw audio samples.
Much more… check out the API documentation!
Getting started
Install
pip install text_game_maker
Run the example map
python -m text_game_maker.example
Writing maps
Write a class that extends the text_game_maker.utils.runner.MapRunner class and implements the build_map (and optionally build_parser) methods. See example-map/example_map.py and the API documentation for reference.
Run text_game_maker.runner with the name of the .py file containing your MapRunner class, e.g.:
python -m text_game_maker.runner mymaprunner.py
In this example, text_game_maker.runner will import the mymaprunner.py file and run the first instance it finds of a class which is a subclass of text_game_maker.utils.runner.MapRunner
To run a MapRunner class as a slackbot to play your game over slack, the procedure is the same, except use the text_game_maker.slackbot_runner script, e.g.:
python -m text_game_maker.slackbot_runner mymaprunner.py
Note that when using the slackbot runner you must have already created a bot user in your slack workspace, and the API token for the bot user must be available in an environment variable named SLACK_BOT_TOKEN.
API Documentation
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 Distributions
Built Distribution
File details
Details for the file text_game_maker-0.7.5-py3-none-any.whl
.
File metadata
- Download URL: text_game_maker-0.7.5-py3-none-any.whl
- Upload date:
- Size: 123.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.8.1 pkginfo/1.2.1 requests/2.12.4 setuptools/33.1.1 requests-toolbelt/0.7.0 clint/0.5.1 CPython/3.5.3 Linux/4.9.0-11-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 345935335359eb74091159be176710ce53ec7912c632a2d35ae30ab761d5214f |
|
MD5 | acd8c5953ee330f9b1c7d8b726fc8889 |
|
BLAKE2b-256 | 9e399369c2086fe418c7602f2b3c7d97dd9e800e64100a4c52a6041f9776fcdd |