Hardware Reference
In-Depth Information
# shuffle up the text boxes
textSurface[i] = textSurface[i-1]
lines = setWords(lines,0)
offset = 0
while offset < textHeight:
checkForEvent()
drawScreen(offset)
offset += scrollSize
time.sleep(3.0)
terminate()
def getNews(): # open news file
global numberOfLines, newsLines
nfile = open(“news.txt”,”r”)
for line in nfile.readlines():
newsLines.append(line)
numberOfLines +=1
nfile.close()
def drawScreen(offset) : # draw to the screen
global segment
screen.blit(background,[0,0]) # set background colour
for index in range(0,segments+1):
segment +=1
if(segment > segments): # wraparound segment number
segment = 0
drawWords(segment,offset)
pygame.display.update()
def setWords(index,segment) :
endOfLine = False
margin = 30 # total gap for the two sides
words = newsLines[index].split() ;
# get an array of words from the line
wordsAvailable = len(words)
wordsToUse = 0
wordsWidth = 0
tryLine = “”
while wordsWidth < screenWidth - ;
margin and wordsAvailable >= wordsToUse + 1:
tryLine = “”
wordsToUse += 1
for test in range(0, wordsToUse):
continued
Search WWH ::




Custom Search