Hardware Reference
In-Depth Information
are clipped, showing only half of the two lines. Finally when the ofset is equal to the height of
the text surface, Surface 0 is fully visible, and Surface 4 is totally clipped. So the words have
scrolled one line simply by changing the ofset variable at a diferent value in successive frames.
Okay, that is enough theory for the moment; it's time to actually implement this in code. his is
not by any means a full, working system, but it allows us to work on this function and get it right
before going on to get closer to what you want. Listing 4-1 contains the initial scrolling code.
Listing 4-1 Scrolling 1
#!/usr/bin/env python
“””
Here is the News
A Raspberry Pi Auto Cue Test 1
“””
import time # for delays
import os, pygame, sys
pygame.init() # initialise graphics interface
os.environ['SDL_VIDEO_WINDOW_POS'] = 'center'
pygame.display.set_caption(“Auto Cue test 1”)
screenWidth = 980
screenHeight =610
screen = pygame.display.set_mode([screenWidth, ;
screenHeight],0,32)
background = pygame.Surface((screenWidth,screenHeight))
segments = 4
segment = 0 # initial start place
textHeight = screenHeight / segments
textSurface = [ pygame.Surface((screenWidth, ;
textHeight)) for s in range(0,segments+1)]
# define the colours to use for the user interface
cBackground =(0,0,0)
cText = (255,255,255)
background.fill(cBackground) # make background colour
font = pygame.font.Font(None, textHeight)
def main():
lines = 5
while True :
for i in range(0,5):
setWords(“This is line “+str(lines-i),i)
Search WWH ::




Custom Search