I am trying to build a mini text based game just as a first project in python. I decided to write my story and content in text files. I am designing the game such that each character from the file is read and immediately printed out to the screen.
liOb = open('loadgame.txt','r')
ch = liOb.read(1)
if ch == "\n": continue
elif ch is None: break
You are Max, a college student who lives a very ordinary life. One
day, you decide to get out of this ordinary life and do something
worth adventurous and be proud of! You skipped college for a week and
worked overtime in your workplace, just to get enough money. For the
past 1 week, you worked 16 hours a day, and had saved enough money for
a cozy little vacation in the small town of Belleyard Upon Tyne. You
pack your bags, and leave your house the next day.
Since you had to spend your money wisely, you decide to spend your
days in a older hotel. You checked in a hotel called The Silver Mare.
Your first two days were spent awesome. However this morning, after
you wake up, you wake up feeling tired. Not only that, few times you
felt someone following and creeping behind you. You looked back
multiple times...... only to notice there's no one there. You ignored
that feeling away as hangover due and prepare to enjoy your remaining
Date : October 21, 1997
Why try to read character by character? Read it all into the buffer at once, and then display it character by character
import sys import time liOb = open('loadgame.txt','r') content=str(liOb.read()) for i in range(len(content)): sys.stdout.write(content[i]) time.sleep(0.002) sys.stdout.flush()