OVERVIEW

Our penny arcade game software has several different modules, each created to handle the differing parts of our game. The major categories are:

Target: manages all events and services related to the eight targets including registering hits on the targets, activating and deactivating the LED and random target selection.  This module also keeps track of the game score.

Shooter: manages all events and services related to the two guns including trigger pulls, activating and deactivating the laser pointer and the vibrator motors in each gun.

LCD: manages the LCD display through a parallel shift register that prints instructions to the user and also displays score and time updates.

Motors: turns the target motors on and off using the PWM module and also controls the SWAG dispensing motor.

In addition to these separate modules, we created a main module to handle these functions as well as some of the smaller miscellaneous tasks. This function is essentially what runs our game and makes all of its components come together and forma complete game.

Click here to see and download the complete Main.c module

Function: main(void)
Description: The main program for the Area 218 project.
Input: None
Output: None
Psuedocode: Initialize Timer, A/D, Motors, CoinSensor, Shooter, Target and LCD modules
Repeat Forever
Wait for a coin to be inserted
Wait for trigger pull
Read in difficulty and game mode
Setup LCD
Start target motors
Initialize Shooter and Target for new game
Initialize 1 second timer
While game not over
If valid trigger pull
Fire shooters
If valid target hit
Register hit with target module
Update LCD score
If shooter timer expired
Turn off shooter
If shooter vibrate timer expired
Turn off vibrator motor
If new target is needed
Activate new target
If 1 second has elapsed
Update LCD time display
Reinitialize 1 second timer
End Shooter, Target and Motor modules
Print final score
Dispense SWAG
End Game Loop
End Reperat Forever Loop
 

COIN SENSOR

The CoinSensor module handles the coin sensing of our game.

Click here to see and download the complete CoinSensor.h module

Click here to see and download the complete CoinSensor.c module

Public Level Functions:

Function: InitCoinSensor(char coin_line)
Description: Initializes the coin-sensing port
Input: char coin_line, which designates the port for sensing the coin
Output: None
Psuedocode: Set coin_line to static variable
Set the coin-sensing port to input

Function: CheckCoinEvent(void)
Description: Checks whether a coin has been inserted
Input: None
Output: char, which reports whether a coin event occured
Psuedocode: Read and store coin port status
If coin port is high
Return indication of coin insertion
Else
Return indication of no coin insertion
End If