How to make a basic Text/Story Game in Python!

How to make a basic text/story game in Python!


Text/story games are a great project to start with when you are first learning how to code. This tutorial will cover how to make a basic one in Python with scrolling text, coloured text, sleeping, options, and clearing the console.

Things to import:

import os
from os import system -- this is to clear the canvas
import time
from time import sleep -- for sleeping 😴
import sys -- for scrolling text
import random -- depending on your game, you might need random numbers.

The scrolling text function:

This will make the text scroll and space out the game better.
Make sure you indent it correctly!

You can change sleep(0.1) to a number that suits your game.

When you have the function down, make sure to use scrollTxt() instead of print()!

Colors to get:

Colors are a great addition to a text game, it will make the text easier to read and less boring.

Here are some basic starter colors:

To use colors:

It will print "Im blue (daba dee ba da die)" except its blue!

Spacing out the game using clear and sleep:

Alright! Now you know how to print scrolling and coloured text. Now, we should space out the game, so it is easier to read and the console isnt messy.

First, sleeping.

To make the output sleep, use time.sleep(time).

For example:

This will make joe say pog, then 1 second after joe finishes saying pog, joette will say pog.

Second, clearing.

To clear the console, use system('clear').

For example:


Options are pretty simple. You just use if and elif.

For example:

Text Game Example!

Ok! Now you should know how to make a basic text/story game. If you are still confused, ill put a short one with all the things I mentioned below.

Thats it! Feel free to comment a question if you have one!

You are viewing a single comment. View All

dang this thing is cool I like it although i added like a bajillion things