Milestone 5

Table of contents

  1. Overview
  2. Resources
    1. Source Code
    2. Making Sound
    3. Battery Charging
  3. Game Specifications
    1. “Last Person Standing”
    2. Configuration Numbers
    3. Sounds
    4. Display
    5. Timers
  4. Implementation Details
  5. Pass Off and Grading
  6. Code Submission

Overview

For this milestone, you will implement a complete game with sound and hopefully have fun with your laser tag system. The game is to support play between 2-10 teams of any number of players. Unlike your other programming assignments, you are free to implement the game as you like, as long as you meet the requirements for game functionality, including sound. The coding standard still applies. This milestone will be accomplished as a team. You should consider how to divide the work so that each team member contributes equitably.


Resources

Source Code

Note that the following files are provided in your ecen390 project directory. Refer to the comments above each function for more detail.

  • ltag/main/config.h
  • ltag/main/game.h
  • ltag/main/invincibilityTimer.h
  • ltag/main/lockoutTimer.h
  • ltag/main/main_m5.c

The following library components are provided with header files (.h). See the header files for details on each function.

  • components/neo/ - NeoPixel driver
  • components/sound/ - Sound driver
  • ltag/components/c32k_16b/ - Laser tag sounds, 32 kHz, 16-bit
  • ltag/components/histogram/ - Draw histogram on LCD
  • ltag/components/panel/ - Draw control and status panel on LCD
  • ltag/components/rx/ - Receive driver

You are expected to create and implement the following files. See the provided header files (.h) for more detail.

  • ltag/main/game.c
  • ltag/main/invincibilityTimer.c
  • ltag/main/lockoutTimer.c

When implementing each function, pay attention to the function descriptions in the header files. In fact, save lost points from the coding checker by copying the comments and function prototypes from the header files to your .c files to start your code. Also, you are likely to lose points from the coding checker if you modify the header files! So, don’t modify the provided header files.

Making Sound

You are provided a working sound driver and laser tag related sound data. The sound driver is initialized in main_m5.c at a sample rate that matches the sound data.

sound_init(CONFIG_SND_SAMPLE_RATE);

Sound data is located in the ltag/components/c32k_16b/ directory. You will want to include all of the sound data header files in game.c so you can play the various sounds during the game.

// Sound data as 'C' arrays
#include "bcFire.h"
#include "clipEmpty.h"
#include "gameBoyStartup.h"
#include "gameOver.h"
#include "ouch.h"
#include "pacmanDeath.h"
#include "powerUp.h"
#include "screamAndDie.h"

A sound is played with a call to sound_start(), passing the array of sound data as an argument. Typically, you will want the wait argument to be false. The following call will play the laser tag shot sound.

sound_start(bcFire, sizeof(bcFire), false);

In this instance, starting the bcFire sound should be done from within the trigger pressed callback function.

Please read sound.h for more detail on the sound functions.

Battery Charging

The battery on your tag unit is charged when a USB cable is connected and the tag unit power switch is turned on. A mini, blue LED will indicate that the battery is being charged. It will turn off when the battery is fully charged.


Game Specifications

The game functions as follows. The game is essentially a version of “last person standing”. The game ends when all of the members of any team but one have “died”. The winning team is the team that has at least one member remaining “alive” at the end of the game.

“Last Person Standing”

  1. Teams can consist of any number of persons; teams should start with the same number of members for fairness.
  2. Each team member has their own laser tag unit.
  3. Team membership is determined by the selected transmit channel. For example, all members of Team-A would use Channel 6, all members of Team-B would use Channel 8, etc.
  4. Each member starts the game with 3 lives. Once all lives are expended, shooting is disabled and the person leaves the game.
  5. The game ends when all members of either team have lost all lives.
  6. No communication between laser tag units is required. Each tag unit functions independently and players drop out of the game as they lose lives. You can tell that the game is over when all members of one team have dropped out of the game and returned to base.

Configuration Numbers

Note that the numbers below have been refined over several playing sessions. The current configuration seems to provide a nice balance of fun game play and low complexity.

  1. Each team member starts with 3 lives.
  2. A team member loses a life when they accumulate 5 hits.
  3. The tag unit has a “clip” that contains 10 shots. Once a player has fired 10 shots they must wait 3 seconds for the clip to “auto-load”.
  4. The player may force a reload of the clip at any time by pulling and holding the trigger for 3 seconds (if the clip contains shots, the initial push of the trigger will fire a shot).
  5. As soon as a hit is detected, all further hits are ignored for 1/2 second. The hit indicator also flashes for 1/2 second.
  6. Immediately after losing a life, a player is invincible (hits are ignored, shots are disabled) for 5 seconds thus giving them time to quickly scurry away.
  7. Hits can be detected on all channels except the players own transmit channel. This prevents self hits and getting hit by a member of your own team.

Sounds

Sound is essential to game play. It informs the player when they have been hit, when they have lost a life, and when they have expended all lives and must drop out of the game. In detail:

  1. A Gameboy startup sound will play when the laser tag unit is first turned on.
  2. A laser-like “fire” sound is played each time a player fires a shot. If the clip is empty, a “click” sound is played when the trigger is pushed.
  3. A “power up” sound is played each time the clip is reloaded (either automatically or manually).
  4. An “ouch” sound is played each time a player is hit.
  5. A “scream and die” sound is played when the player has lost a life.
  6. A Pacman terminating sound is played once a player has lost all lives.
  7. A “game over” voice will inform a player when they must drop from the game and “return to base.”

Display

The display shows several control and status items.

  • Control panel:
    • Transmit mode (TX):
      • on: continuous, useful in focusing the optics
      • shot: 200 ms pulse when trigger is pressed
    • Channel (CH): transmit channel, 0-9
    • Volume (VOL): sound volume 0-100
    • Threshold factor (THRESH): hit sensitivity of the detector in powers of 2
  • Status panel:
    • Lives (LIVES): lives remaining (counts down from 3)
    • Hits (HITS): total hits detected (counts up from 0)
    • Shots (SHOTS): shots remaining (counts down from 10)
  • Histogram: displays the hits received on each channel

The four navigator (NAV) buttons on the laser tag unit interact with the control panel. The value of the control option is highlighted in yellow when selected. Otherwise values are shown in green. Heading text is shown in white.

  • NAV Left: Move control selection left
  • NAV Right: Move control selection right
  • NAV Up: Increment the selected control option
  • NAV Down: Decrement the selected control option

The control panel consists of two rows of characters and the status panel consists of another two rows of characters. The first row of each panel is for the heading and the second is for the value. With a font size of 2, the laser tag unit display can accommodate 20 characters per row. The panel location and block dimensions are specified by x, y, and w in characters. The height is always 2 characters. The following map shows the regions of each panel item. Panel item headings are in capital letters and the values are underneath in lower case letters.

   00000000001111111111
   01234567890123456789
  |--------------------
0 |  TX CH VOL   THRESH
1 |xxxx  c vvv    ttttt
2 |LIVES   HITS   SHOTS
3 |    l     hh      ss
4 |Histogram Area ...

Timers

  • Lockout: The timer is started after a hit is detected. While the timer is active, hits are ignored. This insures that only one hit is detected per timer interval.
  • Invincibility: The timer is started when a life is lost. While the timer is active, hits are ignored and the trigger is disabled.

Implementation Details

Implementation details for this milestone are intentionally limited. This gives you the opportunity to plan your approach as a team without detailed guidance. I highly recommend looking at some of the test code from previous milestones for examples. Feel free to copy test code to jump start your implementation of the game. However, you will be responsible for checking that any “copied” code meets the coding standard.


Pass Off and Grading

Grades for Milestone 5 will be determined by the functionality of the game and the lack of observable bugs. Teams will get credit for each feature that is correctly implemented.

  1. Game startup sound (5%): correctly generating the game startup sound.
  2. Tag unit firing (15%): correctly implementing firing sound, e.g., the tag unit fires a shot when the trigger is pulled and makes a clicking noise when 10 shots have been fired and the unit has not been reloaded (automatically or manually).
  3. Auto and manual reload (15%): correctly implementing the auto and manual load feature with sound; the tag unit auto-loads once the clip is empty and the user can force a manual reload by holding the trigger for the appropriate amount of time.
  4. Hits and lives (15%): correctly keeping track of hits and lives. Flash the hit indicator red when hit and generate the hit sound. Generate the death sound when 5 shots have been accumulated. When not being hit, the hit indicator LEDs should show the team color, which should match the color of the channel on the histogram display (e.g., blue for Ch 6 and green for Ch 8).
  5. End of game (5%): correctly generate the end-of-life game sound, and play the “return to base” sound.
  6. Control and status panel (20%): provide controls for transmit mode, channel, volume and threshold factor. Provide status for the number of lives remaining, total hits accrued, and shots remaining. Display a histogram of shots received on each channel.
  7. Bugs (25%): No detectable bugs. Subtract 5% for each detected bug up to the total for this category. Bugs can include:
    • False hits at any point.
    • Incorrectly keeping track of lives.
    • Undue static.
    • Incorrect game play.

One of the best ways to find bugs in your system is to play it extensively. If the TA detects a bug during pass off, the team can attempt to fix their system and pass off later. However, don’t depend upon the TA to detect bugs in your system. You must test and fully debug your system prior to bringing it to the TAs for pass off. If pass-off attempts become excessive, we will institute a penalty of some sort.


Code Submission

You will use ./check_and_zip.py m5 to prepare your zip file for submission to Learning Suite. It will be checked for adherence to the coding standard. Submit only one .zip file per team. All team members will receive credit.