High Level:
-
USER INPUT:
-
Control for our golf game is the same as for the original 8-bit Nintendo
Entertainment System (NES). We use one controller with the famililar A, B, Select, and
Start buttons, as well as a 4-directional pad. Specific directions for using these
controls are displayed on the LCD. As an added feature, simultaneously pressing the
four buttons restarts the game (similar to some NES games).
-
Program Design
-
The program runs three independent state machines: An Input for the
controller, a debouncer for the controller, and the state machine for the game.
These 3 interact as follows: The controller function polls the nintendo controller
out of PORTC as discussed in the low-level design page, and sets a temporary variable.
This temporary variable is checked by the debouncer program to debounce the input
so input is only taken on the release of the button. The golf game state machine
checks the variable set by the debouncing program in order to check what it should do.
The game state machine has several stages. An early version of the state machine is
included below.
The program enters in a "start screen" mode and continues to check the club, direction of
the swing, and the power of the swing. We took out spin due to time constraints.
The screen display was set up similar to this diagram below:
It is very visible that time constraints caused major scale-backs on the program. The
time constraints were mostly caused by the initial difficulty in using the LCD. Despite
large amounts of documentation on the LCD Controller (SED1330F), it was difficult to set
all of the values correctly to this specific LCD.
Back to the game. Once the inputs of the swing characteristics are inputted, the program
calculates where the ball will go, and store intermediary positions in an array, then
animates this array using delays (We didn't want the user to be able to stop this animation
so we used delay_ms() rather than a state machine). We then send the new location of the ball
to a function that determines if it in a sandtrap, off of the screen, or in the hole.
Depending on which one it is, it updates the display.
|
|