Building game show buzzers with a Raspberry Pi
Operator's Menu – Lines 52 to 56
The terminal.addstr
function is provided three arguments:
terminal.addstr ( 5 , 5 , "Trivia Buzzers and Scoring" )
The first two are the (y, x) coordinates where you want the text to appear. The third argument is the text itself. You can also omit the coordinates and provide terminal.addstr
with a string as the only parameter. In this case, curses will plot the text at whatever position the cursor was left after the previous curses command. Figure 6 shows the buzzer menu running in a terminal.
Loading the Graphics – Lines 58 to 68
The graphics for the public display were created in Photoshop. In the future, when the buzzers are used again, I can load a new set of graphics, and the system will match the theme of the current game or contest. In
numbers = list() left = 0 numbers.append ( ( pygame.image.load ( "numbers_01.jpg" ) , left ) ) left += numbers [ 0 ] [ 0 ].get_width()
numbers
is the Python list that stores the graphics that will be displayed on the LCD when a winner is determined. They are stored as tuples with the graphic itself and the distance from the left side of the display.
The left
variable saves the offset from the left side of the screen for each graphic. Each offset is calculated by getting the cumulative width of previously loaded graphics. It is up to the graphic artist to make sure the total width of all five number displays is the same as the display size. The size of each individual number, however, is not important because the software calculates offsets as the images are loaded.
Buy this article as PDF
Pages: 8
(incl. VAT)