Documente Academic
Documente Profesional
Documente Cultură
Program Guide
This program was written as a prototype for video game publisher MAVCO and designed to be
used on the handheld PROTEUS console. The game allows for single-player use and possesses
both statistic tracking and replay capabilities. Within the program are also options to display the
game instructions and credits.
In “Go, Brutus, Go!” the user’s main objective is to get Brutus Buckeye from one side of the screen
to the other without colliding into any students. At the start of the game, Brutus stands at one end
of the screen, and the students travel across the screen in lines perpendicular to Brutus’ path.
Tapping the screen moves Brutus forward one space, either to a line of traffic or space between
lines. The game ends when a collision occurs or Brutus makes it to the other side. Time is recorded
for the duration of the game, and the high score is the fastest time.
Program Description
The following sections describe the program and its functions in detail. The source code can be
found in Appendix A.
Algorithm/Pseudocode
Include libraries.
Prototype functions.
Main Function
Define variables.
Print title screen (touch to continue).
Print story (touch to continue).
Begin “do…while” loop that keeps program running.
Run start menu function.
Switch-case for user input:
1. Play the game:
a. Show countdown screen.
i. Print “3” for 1 second, “2” for 1 second, and “1” for 1 second.
ii. Run game function.
2. Rules/Instructions:
a. Print rules and instructions to screen.
2
3. Statistics:
a. Print statistics.
4. Credits:
a. Print credits.
End switch case.
Start screen function.
End while loop.
Gameplay Function
Declare variables for positions of Brutus and pedestrians 1, 2, and 3.
Declare variables for x and y position, start time, current time.
Print oval layout to screen.
Print Brutus in original position to screen.
Start timer.
Start while loop:
Print timer to top right of screen.
Print pedestrian to screen.
While position of Brutus does not equal position of pedestrian 1, 2, or 3:
Move position of pedestrian 1 from down the screen.
Move position of pedestrian 2 from down the screen.
Move position of pedestrian 3 from down the screen.
If screen is touched:
Move Brutus forward one space.
Reprint Brutus.
If Brutus position equals pedestrian position:
Print message of loss.
Break while loop.
If Brutus position equals endpoint:
Print message of win.
If current time is less than fastest time:
Store current time as fastest time.
Print message of beating high score.
3
If pedestrian gets to bottom of screen
Reset to top of screen.
Add to pedestrian counter to move across screen.
‘Erase’ pedestrian by writing over in tan color.
Return high score.
Print Oval Function
Declare variables of path 1, 2, 3, 4 locations and path width.
Print Oval layout to screen.
Print Brutus Function
Take in variables of Brutus’s position.
Print Oval layout.
Print Brutus to screen.
Execution of the main program begins by setting the LCD background and font colors and
displaying the title screen. The program then waits for a touch on the screen to display the game
storyline and the player’s objective.
After the user touches the screen again, the “startscreen” function is called and returns the user’s
input choice from the start menu to the variable “status”. A switch-case structure for “status”
determines how the program proceeds, and startscreen is called again outside the switch-case
structure. The switch-case and startscreen call are contained within an indefinite while-loop to
keep the program running until the Proteus is turned off.
Variables
• int high Variable in which the high score will be returned from the gameplay function
to the main function (initialized at 1000).
• int status Variable in which the user’s choice from the start menu will be returned from
the startscreen function to the main function.
• int zero counter to keep program running (initialized at zero).
• float xpos, ypos Position along x and y-axes of user’s touch on touch screen.
4
Function: float gameplay (float highscore)
When the user selects “Play the game!” from the start menu, a countdown prints to the screen and
the gameplay function is called with the argument “high,” the user’s current high score (which is
initialized at zero at the start of the main function). This function runs the game for the user to play
and returns the user’s current high score as the variable “high” in the main function.
Inside the function is a while-loop that moves each pedestrian down the screen 40 pixels with each
loop and then back up to the top of the screen after they reach the bottom. If pressure is detected
on the screen, the Brutus icon is moved to the right 36 pixels. The while-loop ends when the Brutus
icon collides with a pedestrian graphic or if the Brutus icon reaches the other side of the screen.
The corresponding win or loss message is then displayed, and execution is paused until the screen
is touched. After the user touches the screen, the value of the high score is returned to the main
function, and the main function continues executing.
Variables
This function, called at the start of the “printbrutus” function, sets the background color to green
and draws the horizontal pathway to be taken by Brutus as well as the three vertical pedestrian
pathways.
5
Variables
The arguments of the printbrutus function contain the location to which the Brutus Buckeye
graphic is being printed at that point in the execution of the program. This function is called at the
start of the gameplay function with Brutus’ initial x and y-positions as the arguments. Each time
the user taps the screen during the gameplay function, 36 is added to the argument “brutusx,” and
this function is called again to reprint Brutus one space to the right.
Variables
This function prints to the screen a start menu with four options: play the game, display statistics,
display rules and instructions, or display credits. The value of the return variable “status” is
determined by the location of the user’s touch on the screen, and this value is returned to another
variable called “status” in the main function. The startscreen function is called in the main function
after the introductory information is displayed and again after each case in the “switch status”
structure.
Variables
• int status Return value for function; Value is determined by user’s choice from the start
menu (where the user touches the screen on the start menu).
• int xposition, yposition Coordinates for position of user’s touch on screen.
6
Assumptions
It is assumed that the player knows to only touch the screen once to expect a response. When
touching the screen multiple times in a short amount of time while waiting for the program to load,
it causes the game to load with the touch functions already loaded and Brutus moves without
touching him.
The completed “Go, Brutus, Go!” program allows for gameplay by a single user and successfully
executes based on the user’s performance in the game. Containing the majority of the main
function within an indefinite while-loop gives the game the ability to be replayed. This also
allows the high score to be stored for as long as the Proteus remains on.
Limitations of this version of the program include level of difficulty. The gameplay function was
not written with any variations (i.e. pedestrian speed, number of pedestrians) and can therefore
only support one level of difficulty. Additionally, there is no multiplayer mode or way to store
the name of the top score holder integrated within the program.
One of the key issues with the original program was the flashing screen. Originally, the entire
screen was getting cleared and the graphics redrawn each time a pedestrian had to be moved down
the screen. To resolve this, the code was rewritten to “erase” the pedestrian graphic by drawing a
circle of the same color of the path over it, and a new pedestrian graphic was drawn farther down.
Because the screen was no longer getting cleared, however, the timer began printing down the
screen instead of in the corner. This issue was eliminated similarly by drawing a green rectangle
in that location before printing the time to the same location in each loop. These adjustments made
the screen much easier to observe during gameplay.
The startscreen function also required debugging because the original program ran the gameplay
function even if the user selected an option other than “Play the game!” from the start menu. This
issue was a result of misplaced relational operators in the “if” statements that made “Play the
game!” the user’s start menu choice regardless of where the user touched the screen. Once these
were adjusted, the start menu functioned as the user would expect.
For future versions of “Go, Brutus, Go!” it is recommended that multiple levels of difficulty be
integrated in the program to enhance the user’s experience. The method of “erasing” instead of
clearing the screen should continue to be utilized in the gameplay function as it will produce
significantly clearer graphics that are much easier to view than a flashing screen.
7
References
8
APPENDIX A
Source Code
//Video Game Design Project
//Lauren Pham and Kathleen Albert
//Harper 10:20
//include libraries
#include <FEHLCD.h>
#include <FEHUtility.h>
#include <LCDColors.h>
using namespace std;
A2
LCD.WriteLine("needs to get across the");
LCD.WriteLine("Oval to give Urban Meyer");
LCD.WriteLine("the game book.");
LCD.WriteLine("Help Brutus get across");
LCD.WriteLine("the Oval as quickly");
LCD.WriteLine("as possible!");
LCD.WriteLine("Touch screen to continue");
break;
case (2):
A3
//rules and instructions
Sleep(3.0);
break;
case (3):
//statistics
//print statistics
LCD.Clear();
LCD.Write("The high score is ");
LCD.Write(high);
LCD.WriteLine(" seconds");
LCD.WriteLine("touch screen to continue");
Sleep(3.0);
A4
break;
case (4):
//credits
//print credits
LCD.Clear();
LCD.WriteLine("Made by Lauren Pham and");
LCD.WriteLine("Kathleen Albert ");
LCD.WriteLine("in Dec 2017");
LCD.WriteLine("FEH Harper 10:20");
LCD.WriteLine("Video Game Design Project");
LCD.WriteLine("touch screen to continue");
Sleep(3.0);
break;
}//end switch case
//prompt for start menu input
status=startscreen();
}//end while-loop
}//end int main
//GAME FUNCTION
float gameplay(float highscore)
{
//declare variables for touch position, while-loop, timer
float x_position, y_position, start1, currenttime, x=0;
A5
//record starting time
start1=TimeNow();
//print timer
LCD.SetFontColor(DARKGREEN);
LCD.FillRectangle(0,0,50,20);
currenttime=TimeNow()-start1; // calculate current time as difference
LCD.SetFontColor(BLACK); //reset time color to black
LCD.WriteAt(currenttime,0,0); //write current time to screen
}//end if statement
A6
//if current time is less than fastest time
if (currenttime<highscore)
{
//store current time as fastest time
highscore=currenttime;
//print message of beating high score
LCD.WriteLine("!You beat the high score!");
A7
} //end while-loop when released
}
A8
Sleep(1);
} //end while-loop when touched
}
//'erase' pedestrian
LCD.SetFontColor(TAN); //set color to black
LCD.FillCircle(p1x,p1ay,15); //set pedestrian 1a
} //end of while-loop
LCD.Clear();//clear screen
A9
} //end while-loop when touched
while (LCD.Touch(&x_position, &y_position)){
Sleep(1);
} //end while-loop when released
A10
//print options to screen
LCD.SetBackgroundColor(GRAY); //set background color as white
LCD.Clear();
LCD.SetFontColor(SCARLET);
LCD.DrawVerticalLine(147,0,239);
LCD.DrawHorizontalLine(120,0,319);
LCD.WriteAt("Play the",0,0);
LCD.WriteAt("game!",0,20);
LCD.WriteAt("Rules and",0,150);
LCD.WriteAt("Instructions",0,170);
LCD.WriteAt("Statistics",150,0);
LCD.WriteAt("Credits", 150,150);
//for statistics
if (xposition>125&&yposition<142){
status=3;
}
//for credits
if (xposition>125&&yposition>152){
status=4;
}
return(status);
} //end start screen function
A11