Hardware Reference
In-Depth Information
of which is to use a lookup table that contains a bitmap for each letter in the font you want
to render. If you render into a separate area of memory, you can transfer that memory to any
location in the screen memory by a process Pygame calls blitting.
So armed with this knowledge you can work out a strategy for scrolling words. Render each
line of the display into its own surface memory, and then blit each surface into the screen
memory, one line above the next. he Y coordinate for each line is simply incremented in
steps of the window height divided by the number of lines. hen all the lines it completely
within the window. If you have another number, a vertical ofset, that you subtract from the
calculated Y position, then the display will have each line shown in a slightly diferent place.
If that ofset is changed slightly and the screen redrawn repeatedly, the words will appear to
scroll up the screen. Figure 4-3 shows what is happening.
Figure 4-3:
Scrolling part 1
- the ofset
value controlling
the position of
the lines.
You can see the surface memory for each line and how it lines up with the screen. Surface 0 is
entirely below the screen and so gets lost or clipped from the inal display. As the ofset increases
to half the height of the text surfaces, the top half of Surface 4 and the bottom part of Surface 0
Search WWH ::




Custom Search