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:
from os import system -- this is to clear the canvas
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
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.
To make the output sleep, use
This will make joe say pog, then 1 second after joe finishes saying pog, joette will say pog.
To clear the console,
Options are pretty simple. You just use if and elif.
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.