Marquee design and control (optional)

In this task, we will implement the marquee control for our arcade game. We will display information such as the player's turn (whether it is the computer or the human player's turn), the winner of the game at the end (or whether it was a tie), or game-specific messages on the marquee. We will use the Pi Lite LED Matrix display (http://shop.ciseco.co.uk/pi-lite-lots-of-leds-for-the-raspberry-pi-1206-red/) that can be used to scroll messages across the display.

Marquee design and control (optional)

Pi Lite – Courtesy: The Ciseco PLC website

Prepare for lift off

The Pi Lite display can be purchased from the Ciseco PLC website (http://shop.ciseco.co.uk/pi-lite-lots-of-leds-for-the-raspberry-pi-1206-red/). The display costs about 33 USD.

One of the requirements is the serial library, which is required to control the display. It can be installed as follows:

sudo apt-get install python-serial

Once we are done installing the module, we should be able to import the module and start programming the messages in our game. The Ciseco Pi-Lite GitHub repository comes with examples such as the Bar Scroll example. It is essential that you download such examples and test if the python-serial module is functionally correct.

Engage thrusters

  1. We will get started by importing the serial module and initializing the serial port parameters, including the baud rate and port name:
    import serial
    serialport = serial.Serial()
    serialport.baudrate = 9600
    serialport.timeout = 0
    serialport.port = "/dev/ttyAMA0"
  2. After initialization, the serial port is opened to start scrolling the messages across the display:
    try:
      serialport.open()
     except serial.SerialException, e:
      sys.stderr.write("could not open port %r: %s
    " % (port, e))
  3. As an example, we will display the Welcome to Connect Four Game message in the main game menu:
    column = pfio.read_input()
    serialport.write("Welcome to Connect Four Game")
    pygame.display.update()

Objective complete – mini debriefing

In this task, we finished integrating the LED display to Raspberry Pi that runs the game.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.159.224