Skip to main content

A textual simple game engine powered by Python and Pygame.

Project description

Textipy : An Adventure Text Game Engine

An easy way to create rpg text games using Python.

Getting Started

  1. Install Python 3.9 or newer. https://www.python.org/downloads/

  2. Open cmd/terminal and type:

     pip install -i https://test.pypi.org/simple/ textipy
    

If you want to install the newest version from git use this command:

    mkdir mygame
    cd mygame
    pip install git+https://github.com/younessidbakkasse/textipy

If you want to easily edit the source, it's recommended to clone the git repo and install as develop like this. Make sure you have git installed. https://git-scm.com/

    git clone https://github.com/younessidbakkasse/textipy

Also install pygame module using this command:

    pip install pygame

On some systems you might have to use pip3 instead of pip in order to use Python 3 and not the old Python 2.

Dependencies

  • pygame 1.9+

Examples

from textipy import *            # this will import everything we need from the engine manager with just one line.

game.run()                       # opens a window and starts the game.

How do I make a game?

This game engine is writing in 100% Python code. You can use any text editor you want, but personally I like to use Vscode.

  1. Create an empty .py file called 'my_game.py' avoid names like game.py, manager.py, scene.py
  2. Copy this text into your new file:
from textipy import *          


# always chose 'Pregame' as a name of the first scene
game.scenes['Pregame'] = StoryScene(
        name = 'Pregame',  #the name is required so that you can link scenes with each others.
        buttons = [['Start the game', 'second scene', 'normal']],  #the first element is the text on the button
        text = "The front door has been left slightly ajar. Partialy broken, it may have been opened by force." # the scene text
)

game.run()                       # opens a window and starts the game.
  1. Type this in the terminal to start the game:

    python my_game.py
    

    If you use Vscode, I recommend installing the python extension to tun on your scripts with the press of a button.

  2. you can now control the game there a gui button such as inventory or profile, you can exit the game using the menu selection exit game.

  3. to link two scenes you need to create a sceond scene exemple below, and add it's name to the button destination list parameter, so when you click the button you directly convert the second scene.

from textipy import *            # this will import everything we need from the engine manager with just one line.

game.scenes['Pregame'] = StoryScene(
        name = 'Pregame',  #the name is required so that you can link scenes with each others.
        buttons = [['Start the game', 'Second Scene', 'normal']],  #the first element is the text on the button
        text = "The front door has been left slightly ajar. Partialy broken, it may have been opened by force." # the scene text
)

game.scenes['Second Scene'] = StoryScene(
        name = 'Second Scene',  #the name is required so that you can link scenes with each others.
        buttons = [
                ['Fight the dragon', 'third scene', 'fight-wild dog'], #first button
                ['Run away', 'third scene', 'normal'] # second button
        ],  
        # here third scene is not yet created
        text = "You just met a wild dog do you want to fight him or run away" # the scene text
)

game.run()                       # opens a window and starts the game.

Contributions

Any pull requests are welcomed! We will have the code checked carefully. Please contact me at : std.youness@gmail.com if you have any thoughts on how to make this a better project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for textipy, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size textipy-1.0.0.tar.gz (15.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page