I've found a Python version of the classic text-based 'Star Trek' game. It writes loads of text to the console for star-field displays etc.
I'd like to rewrite it with a static text display that updates in place, and though that the 'scene' module would be the best way to do it, but I'm obviously not understanding how the 'scene' module works.
For example: I want to display the intro text, so I've coded the following:
import console
from scene import *
import time
class MyScene(Scene):
def draw(self):
pass
def setup(self):
global screen
screen = self.size
w, h = self.size.w, self.size.h
self.graphicBlurb()
def graphicBlurb(self):
blurb = []
blurb.append("Space ... the final frontier.")
blurb.append("These are the voyages of the starship Enterprise")
blurb.append("Its five year mission ...")
blurb.append("... to boldly go where no-one has gone before")
blurb.append("You are Captain Kirk.")
blurb.append("Your mission is to destroy all of the Klingons in the galaxy.")
#font_size = 60 if self.size5.w > 700 else 40
yOffset = screen.h/(len(blurb))
yPos = screen.h
for line in blurb:
text(line,'GillSans',40,screen.w/2,yPos)
print "Printing {0} {1}".format(line,time.localtime())
time.sleep(1.5)
yPos -= yOffset
trekGame = MyScene()
run(trekGame)
but when I run this, instead of the lines of text appearing one at a time down the screen, I get a black screen for about 10.5 seconds, then all the text appears at once.
I'm guessing that it's running the 'setup' method but nothing is appearing on screen until the 'draw' method is called.
What's the best way to do this, or is 'scene' only for programs that need to 60fps gameloop and should I be using the 'ui' module instead?
Thanks,
Steve