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.

Figure 6: The operator's menu can simulate a player buzz-in, enable the buzzers to display a winner, and reset (clear the screen). Exiting is also possible, but no confirmation is requested, so the operator is warned on the menu.

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

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Creating a multiplayer quick-reaction game

    The quick-reaction game provides an introduction to building simple circuits with the Raspberry Pi and controlling those circuits with ScratchGPIO, an advanced version of Scratch.

  • A Python interface to a large-format pen plotter

    Getting a large-format plotter operational presented a personal challenge. A Raspberry Pi with a USB-to-serial dongle was the easiest way to start plotting on my home network.

  • Pygame modules for interactive programs

    Pygame modules are particularly suited to programming highly interactive software. We look at the modules dedicated to events, sound, and input by keyboard, mouse, and game controller.

  • Graphical displays with Python and Pygame

    As its name implies, Pygame is a set of Python modules designed to write games. However, many Pygame modules are useful for any number of projects. We introduce you to a few Pygame modules that you can use to create custom graphical displays for your project.

  • Fast clocks, model railroads, LED displays, and more

    Some model train enthusiasts like to run their trains like a real railroad with a dispatcher controlling movements, issuing train orders, and making sure the train stays on schedule. But, time runs differently for these trains, thanks to fast clocks.