D. Final Code

#include <FEHIO.h>

#include <FEHLCD.h>

#include <FEHUtility.h>

#include <FEHAccel.h>

#include <LCDColors.h>

 

int main()

{

//Defining all of the variables, integers and floats

int Title, Start, Rules, Stat, Cred, playgame = 1, object1 = 200;

float play_time, end_time, obj1_time, Start_x, Start_y, dx, dy, head_center = 160, body_center = 160, arms_left = 145, arms_right = 175, tilt;

//Creating the main menu for when the Proteus is turned on

LCD.Clear( FEHLCD::Blue );

LCD.SetFontColor( FEHLCD::Black );

//Drawing the rectangle (to push) for the different menu options

LCD.SetFontColor( FEHLCD::Blue );

LCD.DrawRectangle(0, 0, 319, 48);

LCD.SetFontColor( FEHLCD::Black );

//Title of the game

LCD.WriteAt(“Dilly Dodge Dip”, 0, 4);

//Rectangle and text for the play game button

LCD.SetFontColor( FEHLCD::Blue );

LCD.DrawRectangle(0, 48, 319, 47);

LCD.SetFontColor( FEHLCD::Black );

LCD.WriteAt(“(1) Play Game”, 0, 52);

//Rectangle and text for the rules/instructions button

LCD.SetFontColor( FEHLCD::Blue );

LCD.DrawRectangle(0, 95, 319, 47);

LCD.SetFontColor( FEHLCD::Black );

LCD.WriteAt(“(2) Rules/Instruction”, 0, 99);

//Rectangle and text for the stat button

LCD.SetFontColor( FEHLCD::Blue );

LCD.DrawRectangle(0, 142, 319, 47);

LCD.SetFontColor( FEHLCD::Black );

LCD.WriteAt(“(3) Statistics”, 0, 146);

//Rectangle and text for the credits button

LCD.SetFontColor( FEHLCD::Blue );

LCD.DrawRectangle(0, 189, 319, 50);

LCD.SetFontColor( FEHLCD::Black );

LCD.WriteAt(“(4) Credits”, 0, 193);

 

//Coding for Start touch

 

while(!LCD.Touch(&Start_x, &Start_y)){}

 

while(LCD.Touch(&dx, &dy)){}

 

//Depending on where the initial start push is, a different screen will pop up

if((Start_y > 48 && Start_y < 95))

{

LCD.Clear( FEHLCD::Blue );

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

//When the game is started, a timer is set for the gameplay and for when the objects enter the screen

play_time = TimeNow();

end_time = play_time + 20.0;

obj1_time = end_time – 5.0;

 

//Game starts for a time of 20 seconds

//Moving while tilted

 

//This bit constantly tests (for 20 seconds) the tilt and moves the character depending on the output form Accel.X()

while(TimeNow() <= end_time)

{

tilt = Accel.X();

 

 

 

 

//If tilt is right, move right based on the amount of tilt

//The next 6 “if” statements erase the previous character and draw another on a certain amount of pixels away depending on the tilt //variable’s value

if(tilt > 0 && tilt < .2);

{

LCD.SetFontColor( FEHLCD::Blue );

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

LCD.SetFontColor( FEHLCD::Black );

head_center = head_center + 2;

body_center = body_center + 2;

arms_left = arms_left + 2;

arms_right = arms_right + 2;

 

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

}

 

if(tilt > .2 && tilt < .6);

{

LCD.SetFontColor( FEHLCD::Blue );

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

LCD.SetFontColor( FEHLCD::Black );

head_center = head_center + 4;

body_center = body_center + 4;

arms_left = arms_left + 4;

arms_right = arms_right + 4;

 

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

}

 

if(tilt > .6 && tilt < 1);

{

LCD.SetFontColor( FEHLCD::Blue );

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

LCD.SetFontColor( FEHLCD::Black );

head_center = head_center + 6;

body_center = body_center + 6;

arms_left = arms_left + 6;

arms_right = arms_right + 6;

 

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

}

 

//If tilt is left, move left based on the amount of tilt

 

if(tilt > -.2 && tilt < 0);

{

LCD.SetFontColor( FEHLCD::Blue );

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

LCD.SetFontColor( FEHLCD::Black );

head_center = head_center – 2;

body_center = body_center – 2;

arms_left = arms_left – 2;

arms_right = arms_right – 2;

 

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

}

 

if(tilt > -.6 && tilt < -.2);

{

LCD.SetFontColor( FEHLCD::Blue );

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

LCD.SetFontColor( FEHLCD::Black );

head_center = head_center – 4;

body_center = body_center – 4;

arms_left = arms_left – 4;

arms_right = arms_right – 4;

 

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

}

 

if(tilt > -1 && tilt < -.6);

{

LCD.SetFontColor( FEHLCD::Blue );

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

LCD.SetFontColor( FEHLCD::Black );

head_center = head_center – 6;

body_center = body_center – 6;

arms_left = arms_left – 6;

arms_right = arms_right – 6;

 

LCD.DrawCircle(head_center, 20, 10);

LCD.DrawVerticalLine(body_center, 30, 60);

LCD.DrawHorizontalLine(35, arms_left, arms_right);

}

 

//For the first 15 seconds of the game, a circle will appear and move up the screen pixel by pixel while erasing the previous one

while(TimeNow() <= obj1_time)

{

LCD.DrawCircle(50, object1, 15);

LCD.SetFontColor( FEHLCD::Blue);

LCD.DrawCircle(50, object1, 15);

object1 = object1 – 1;

LCD.SetFontColor( FEHLCD::Black);

}

 

}

}

 

//If the initial button push is the “rules/instruction” one, then this screen will pop up with the following text

if((Start_y > 95 && Start_y < 142))

{

LCD.Clear( FEHLCD::Blue );

LCD.WriteLine(“The rules of this game are simple:”);

LCD.WriteLine(“The player will have 20 seconds to dodge all of the incoming objects!”);

LCD.WriteLine(“Tilt the Proteus to move Dip in order to avoid being hit”);

LCD.WriteLine(“Good Luck!”);

LCD.WriteLine(” “);

LCD.WriteLine(“Double tap the button on the top of the Proteus to return to the main screen”);

}

 

//If the initial button push is the “stats” one, then this screen will pop up with the following text

if((Start_y > 142 && Start_y < 189))

{

LCD.Clear( FEHLCD::Blue );

LCD.WriteLine(“Stats:”);

LCD.WriteLine(“Game finished on December 5th, 2018″);

LCD.WriteLine(” “);

LCD.WriteLine(“Double tap the button on the top right of the Proteus to return to the main screen”);

 

}

//If the initial button push is the “Credits” one, then this screen will pop up with the following text

if((Start_y > 189 && Start_y < 239))

{

LCD.Clear( FEHLCD::Blue );

LCD.WriteLine(“Credits:”);

LCD.WriteLine(“Created by Michael Wilberding & Matthias Gruich”);

LCD.WriteLine(“And help from Dip Patel, Dr. Parke, and Jared Mitten”);

 

}

 

 

 

}

//If we had more availability to work with the Proteus to test run our code, we could have made much more progress…

//We would have added more than one object to dodge, each with different shapes, by using the same method used for the circle above

//We also would have worked out how to use the tilt function properly, to move the character on the screen, because it was having a problem updating the “tilt” variable to enable different motions to execute

//There would have been usage of a “switch case” and “do-while” loops to create user input into different options in the game

//We also would have added more aesthetic appeal to the character and the menus, alongside subtle comedy such as Dip’s (the character) lifetime in the game, and objects floating such as “Pesky FEH student’s questions” that he had to avoid

//We had extra ideas of more features such as a health bar, to give Dip more than one life, and different levels of difficulty with larger and faster objects

//With more availability in the code-testing stage of the development of “Dilly Dodge Dip”, we would have been able to implement all of these features and upgrades.