You are on page 1of 52

#include "FEHLCD.

h"

#include "FEHRandom.h"

#include "FEHSD.h"

#include "FEHUtility.h"

#include <math.h>

#include <time.h>

class snow {

public:

int numberhits = 0;

int xcoord;

int ycoord;

float speed;

int color, aimx, aimy;

float start_time;

int print_time=30;

int throwball;

int menux, menuy;

int hit=0;

int numberOfTeleport=0;

float snowballsThrown=0.0;

int t_time;
float timeplayed = 0;

int bossesbeat = 0;

void Showmenu(); //Created by Will Terrell

void Showinstructions(); //Created by Michael Terveer

void Showstats(); //Created by Austin Stewart and Michael Terveer

void Showcredits(); //Created by Michael Terveer

void Timer(); //Created by Austin Stewart

void Opponent(); //Created by Austin Stewart and Michael Terveer

void Throwsnow(); //Created by Will Terrell

void DrawBoard(); //Created by Michael Terveer

void Difficulty(); //Created by Michael Terveer

void Backstory(); //Created by Will Terrell

void DrawSnowflake(int a, int b); //Created by Will Terrell

void Showresults(); //Created by Austin Stewart

};

int main()

snow snow1, snow2;


/*Create a while loop so the user can return to the main menu*/

while (1)

snow1.Showmenu();

/*Send to specific function if clicked in specific place*/

if (snow1.menux <= 120 && snow1.menuy <= 29)

snow1.Showinstructions();

else if (snow1.menux <= 120 && (snow1.menuy < 61 && snow1.menuy >=29))

snow2.Showstats();

else if (snow1.menux <= 120 && (snow1.menuy < 91 && snow1.menuy >=61))

snow1.Showcredits();

else /*Play Game*/

{
snow1.numberhits = 0;

snow1.print_time = 30;

snow1.bossesbeat = 0;

snow1.snowballsThrown = 0;

snow1.Backstory();

//Loop while timer is still going and user hasn't beat all enemy

while ((snow1.print_time > 0)&&(snow1.numberhits <=6))

snow1.Difficulty();

snow1.DrawBoard();

snow1.Timer();

//Loop while timer is still going and user hasn't hit anything

while ((snow1.print_time > 0)&&(snow1.hit < 1))

snow1.Timer();

snow1.Opponent();

if (snow1.throwball)

snow1.Throwsnow();

}
//Show results, stats, and add to overall stats

snow1.Showresults();

snow1.Showstats();

snow2.numberhits += snow1.numberhits;

snow2.bossesbeat += snow1.bossesbeat;

snow2.snowballsThrown += snow1.snowballsThrown;

/*

Showmenu() – Created by Will Terrell

The Showmenu() function displays the menu for the game when

the simulator is opened. It displays multiple items,

including the title of the game, the board, as well as

Brutus and his enemies. The function also draws the boxes

for the user to click to go to the Instructions, Statistics,

and Credits pages before also displaying “Click Anywhere

to Play” in the middle of the game board.

*/
void snow::Showmenu()

/*Create a while loop so the user can return to the main menu*/

numberhits = 0;

/*Clear the screen to black*/

LCD.Clear();

/*

Draw the board

*/

//Display name of game

LCD.SetFontColor(WHITE);

LCD.WriteAt("SN",190,1);

LCD.SetFontColor(SCARLET);

LCD.WriteAt("OSU",212,1);

/*Draw left border of board*/

int leftcounter = 0;

for (leftcounter; leftcounter < 12; leftcounter++){


int leftcircley = 31;

int leftrectangley = 35;

leftcircley = leftcircley + (leftcounter * 16);

leftrectangley = leftrectangley + (leftcounter * 16);

LCD.SetDrawColor(SCARLET);

LCD.FillCircle(3, leftcircley, 4);

LCD.SetDrawColor(GRAY);

LCD.FillRectangle(0, leftrectangley, 8, 8);

/*Draw right border of board*/

int rightcounter = 0;

for (rightcounter; rightcounter < 13; rightcounter++){

int rightcircley = 11;

int rightrectangley = 0;

rightcircley = rightcircley + (rightcounter * 16);

rightrectangley = rightrectangley + (rightcounter * 16);

LCD.SetDrawColor(SCARLET);

LCD.FillCircle(316, rightcircley, 4);

LCD.SetDrawColor(GRAY);

LCD.FillRectangle(312, rightrectangley, 8, 8);


}

LCD.FillRectangle(312, 208, 8, 8);

/*Draw bottom left side border*/

int bottomcounter1 = 0;

for (bottomcounter1; bottomcounter1 < 7; bottomcounter1++){

int bottomcircle1x = 10;

bottomcircle1x = bottomcircle1x + (bottomcounter1 * 20);

LCD.SetDrawColor(WHITE);

LCD.FillCircle(bottomcircle1x, 229, 10);

/*Draw bottom right side border*/

int bottomcounter2 = 0;

for (bottomcounter2; bottomcounter2 < 7; bottomcounter2++){

int bottomcircle2x = 309;

bottomcircle2x = bottomcircle2x - (bottomcounter2 * 20);

LCD.SetDrawColor(WHITE);

LCD.FillCircle(bottomcircle2x, 229, 10);


}

/*Draw the player and their snowball*/

LCD.FillCircle(165, 211, 5);

LCD.SetDrawColor(BROWN);

LCD.FillCircle(160, 223, 7);

LCD.SetDrawColor(SCARLET);

LCD.FillRectangle(158, 230, 5, 10);

/*

Display options and read users touch

*/

//Draw rectangles behind menu options

LCD.SetDrawColor(GRAY);

LCD.FillRectangle(0,0,120,29);

LCD.SetDrawColor(SCARLET);

LCD.FillRectangle(0,29,120,32);

LCD.SetDrawColor(GRAY);

LCD.FillRectangle(0,61,120,30);
/*Display the different options for the menu*/

LCD.SetFontColor(WHITE);

/*Viewing Instructions*/

LCD.WriteAt("Instructions", 0, 7);

/*Viewing Statistics*/

LCD.WriteAt("Statistics",0,37);

/*Viewing Credits*/

LCD.WriteAt("Credits", 0, 68);

//Draw Opponents

LCD.SetDrawColor(BROWN);

LCD.FillCircle(60, 160, 7);

LCD.SetDrawColor(PURPLE);

LCD.FillRectangle(57, 167, 5, 10);

LCD.SetDrawColor(BROWN);

LCD.FillCircle(100, 160, 7);

LCD.SetDrawColor(SKYBLUE);

LCD.FillRectangle(97, 167, 5, 10);


LCD.SetDrawColor(BROWN);

LCD.FillCircle(140, 160, 7);

LCD.SetDrawColor(GREEN);

LCD.FillRectangle(137, 167, 5, 10);

LCD.SetDrawColor(BROWN);

LCD.FillCircle(180, 160, 7);

LCD.SetDrawColor(BLUE);

LCD.FillRectangle(177, 167, 5, 10);

LCD.SetDrawColor(BROWN);

LCD.FillCircle(220, 160, 7);

LCD.SetDrawColor(GRAY);

LCD.FillRectangle(217, 167, 5, 10);

LCD.SetDrawColor(BROWN);

LCD.FillCircle(260, 160, 7);

LCD.SetDrawColor(YELLOW);

LCD.FillRectangle(257, 167, 5, 10);

/*Show blinking message to start game until user touches screen*/

LCD.SetFontColor(SCARLET);

LCD.SetDrawColor(BLACK);
LCD.ClearBuffer();

while (!LCD.Touch(&menux, &menuy))

LCD.WriteAt("Click Anywhere To Play",70,120);

Sleep(1.0);

LCD.FillRectangle(60,116,200,26);

Sleep(1.0);

/*

Showinstructions() – Created by Michael Terveer

The Showinstructions() function prints the instructions to the

game. The function runs if the user clicks the Instructions

box in the main function. After displaying the guidelines,

the function prompts the user to click the screen to

return to the main menu.

*/

void snow::Showinstructions()

//Write instructions to screen


LCD.Clear();

LCD.SetFontColor(WHITE);

LCD.WriteLine("INSTRUCTIONS");

LCD.WriteLine("1) Goal: Hit enemies with snowballs");

LCD.WriteLine(" before time runs out");

/*Draw enemy after that line*/

LCD.SetDrawColor(BROWN);

LCD.FillCircle(280, 55, 7);

LCD.SetDrawColor(BLUE);

LCD.FillRectangle(278, 62, 5, 10);

Sleep(.5);

LCD.WriteLine("2) Click on enemy to throw");

LCD.WriteLine(" snowball at them.");

// Draw crosshairs to show aim

LCD.SetDrawColor(SCARLET);

LCD.DrawCircle(280,110,5);

LCD.DrawHorizontalLine(110, 291, 269);

LCD.DrawVerticalLine(280, 99, 121);

LCD.WriteLine("3) Enemies increase in difficulty as");


LCD.WriteLine(" game proceeds.");

LCD.WriteLine("4) If time runs out, you lose.");

/*Have the user click the screen to return to the main menu*/

int e, f;

LCD.SetDrawColor(BLACK);

LCD.ClearBuffer();

while (!LCD.Touch(&e, &f))

LCD.WriteAt("Click anywhere to return to menu", 30, 220);

Sleep(1.0);

LCD.FillRectangle(20,210,300,30);

Sleep(1.0);

/*

Showstats() – Created by Austin Stewart and Michael Terveer

The Showstats function shows the overall stats for the user

since the program was opened. The function runs if the

user clicks the Statistics box in the main function.

It displays information such as the number of snowballs


thrown, the number of enemies hit, the accuracy of the

user, and the number of bosses the user has defeated.

After displaying the overall statistics, the function

prompts the user to click the screen to return to the

main menu.

*/

void snow::Showstats()

//Calculate accuracy

float accuracy;

if (snowballsThrown == 0){

accuracy = 0.0;

else{

accuracy = (numberhits/snowballsThrown)*100;

//Display stats

LCD.Clear();

LCD.SetFontColor(WHITE);

LCD.WriteLine("STATISTICS");

LCD.Write("Snowballs Thrown: ");


LCD.WriteLine(snowballsThrown);

LCD.Write("Enemies Hit: ");

LCD.WriteLine(numberhits);

LCD.Write("Accuracy (%): ");

LCD.WriteLine(accuracy);

LCD.Write("Bosses Beat: ");

LCD.WriteLine(bossesbeat);

/*Have the user click the screen to return to the main menu*/

int c, d;

LCD.SetDrawColor(BLACK);

LCD.ClearBuffer();

while (!LCD.Touch(&c, &d))

LCD.WriteAt("Click anywhere to return to menu", 30, 220);

Sleep(1.0);

LCD.FillRectangle(20,210,300,30);

Sleep(1.0);

/*

Showcredits() – Created by Michael Terveer


The Showcredits() function prints the credits for the

game. The function begins once the user touches the

credits box in the main function. Following this action,

it displays the names of the creators, a thank you

statement, and references used in developing the game.

Next, the function prompts the user to return to the

main menu by clicking the screen.

*/

void snow::Showcredits()

//Write credits to screen

LCD.Clear();

LCD.SetFontColor(WHITE);

LCD.WriteLine("CREDITS");

LCD.WriteLine("Created by Austin Stewart, Will Terrell,");

LCD.WriteLine(" and Michael Terveer");

LCD.WriteLine("Special thanks to Dr Parke and the TAs ");

LCD.WriteLine(" for their support and guidance");

LCD.WriteLine("Resources");

LCD.WriteLine("FEH Proteus Simulator Docs:");

LCD.WriteLine(" API Reference");


/*Have the user click the screen to return to the main menu*/

int g, h;

LCD.SetDrawColor(BLACK);

LCD.ClearBuffer();

while (!LCD.Touch(&g, &h))

LCD.WriteAt("Click anywhere to return to menu", 30, 220);

Sleep(1.0);

LCD.FillRectangle(20,210,300,30);

Sleep(1.0);

/*

Backstory() – Created by Will Terrell

The Backstory() function simply prints to the screen the

story that precedes the gameplay. An interesting feature

of the function is that for the first six seconds, the

user can skip the introduction by touching the screen.

In addition to this aspect, the function also features

a peak at the teleportation of the enemy, a mural of

Brutus the Buckeye, and the random drawing of snowflakes

using the DrawSnowflake() function before displaying

the main title screen.


*/

void snow::Backstory()

//Start Story

LCD.Clear();

LCD.SetFontColor(WHITE);

LCD.WriteLine(" ");

LCD.WriteLine(" ");

LCD.WriteLine(" It was the winter of 2020 and the Covid");

LCD.WriteLine(" Virus had reached its peak.");

LCD.WriteLine(" It was a horrible time in the world,");

LCD.WriteLine(" but for a few special people,");

LCD.WriteLine(" the virus gave them...");

LCD.WriteLine(" ");

//If Possible figure out skipping intro

LCD.SetFontColor(GRAY);

LCD.Write("Click to skip Intro");

//Allow user to skip intro if they want to for six seconds

int a,b;

LCD.ClearBuffer();
Sleep(1.0);

if (!LCD.Touch(&a,&b))

Sleep(1.0);

if (!LCD.Touch(&a,&b))

Sleep(1.0);

if (!LCD.Touch(&a,&b))

Sleep(1.0);

if (!LCD.Touch(&a,&b))

if (!LCD.Touch(&a,&b))

if (!LCD.Touch(&a,&b))

LCD.Clear();

LCD.SetFontColor(WHITE);

LCD.WriteLine(" The Power of Teleportation...");

//Show teleportation for a lil bit

for (int k=0; k<5; k++)


{

/*Generate a Random x-coordinate from 20-300 */

int a = (RandInt() % 280);

a += 20;

/*Generate a Random y-coordinate 20-220*/

int b = (RandInt() % 200);

b += 20;

/*Draw a person at the randomly generated position*/

LCD.SetDrawColor(BROWN);

LCD.FillCircle(a, b, 7);

LCD.SetDrawColor(BLUE);

LCD.FillRectangle(a-2, b+7, 5, 10);

Sleep(.5);

//Erase person after sleep time

LCD.SetDrawColor(BLACK);

LCD.FillCircle(a, b, 7);

LCD.FillRectangle(a-2, b+7, 5, 10);

}
//Wait 1 second before next message

Sleep(1.0);

LCD.Clear();

LCD.WriteLine(" ");

LCD.WriteLine(" ");

LCD.WriteLine(" The evil Dr. Parke and his TAs ");

LCD.WriteLine(" were among the few to get the power. ");

LCD.WriteLine(" Driven mad by isolation");

LCD.WriteLine(" and the lack of Ohio State football,");

LCD.WriteLine(" They decided to rebel...");

//Wait 6 sec

Sleep(6.0);

LCD.Clear();

LCD.WriteLine("");

LCD.WriteLine("");

LCD.WriteLine("");

LCD.WriteLine("");

LCD.WriteLine(" Now, there is only one man");

LCD.WriteLine(" that can save the day...");


//Wait 3 sec

Sleep(3.0);

//Draw Brutus Face

LCD.Clear();

LCD.SetDrawColor(GRAY);

LCD.FillRectangle(0,0,320,240);

LCD.SetDrawColor(DARKRED);

LCD.FillRectangle(70,200,180,40);

LCD.SetDrawColor(BLACK);

LCD.FillCircle(160,110,100);

LCD.SetDrawColor(BROWN);

LCD.FillCircle(160,110,80);

//Continue message

LCD.WriteLine("");

LCD.WriteLine("");

LCD.WriteLine("");

LCD.WriteLine("");

LCD.WriteLine(" Brutus!");

LCD.WriteLine(" The Snowball Throwing Buckeye!");


//Wait 3 sec

Sleep(3.0);

//Add suspense

LCD.Clear();

Sleep(1.0);

//Print our name

LCD.WriteLine("");

LCD.WriteLine("");

LCD.WriteLine("");

LCD.WriteLine("");

LCD.WriteLine(" Two and a Half Men Productions");

LCD.WriteLine(" Presents:");

//Wait 4 sec

Sleep(4.0);

// Draw snowflakes randomly

LCD.Clear();

for (int m=0; m<25; m++)

{
int c, d;

c = RandInt()%310 + 5;

d = RandInt()%230 + 5;

DrawSnowflake(c,d);

//Wait half a sec

Sleep(.5);

//Erase any snowflakes in this portion

LCD.SetDrawColor(BLACK);

LCD.FillRectangle(70,100,180,50);

//write game title

LCD.WriteLine("");

LCD.WriteLine("");

LCD.WriteLine("");

LCD.WriteLine("");

LCD.SetFontColor(LCD.Scarlet);

LCD.WriteLine(" SNOSU");

LCD.SetFontColor(LCD.Gray);

LCD.WriteLine(" The Battle for Campus");


//Wait 4 sec and return to previous function

Sleep(4.0);

//End if statements that allow user to skip intro

/*

DrawSnowflake() – Created by Will Terrell

The DrawSnowflake() function draws a snowflake at a

random position on the screen based on the random x and

y-coordinates generated in the Backstory() function.

In union with a for loop, the function draws a total of

25 snowflakes to the screen at random positions to

imitate snowflakes falling to the ground before the

Backstory() function displays the title screen on the

game.
*/

void snow::DrawSnowflake(int a, int b)

LCD.SetDrawColor(WHITE);

LCD.DrawVerticalLine(a, b-5, b+5);

LCD.DrawHorizontalLine(b, a+5, a-5);

LCD.DrawLine(a+3, b+3, a-3, b-3);

LCD.DrawLine(a+3, b-3, a-3, b+3);

/*

Difficulty() – Created by Michael Terveer

The Difficulty() function determines what level the user

is on and what specifications are made for the level.

The function begins by clearing the screen and then

determines which opponent is to be faced based on the

number of hits the user currently has. In each case,

the stage number, opponent, and location are displayed.

Additionally, the speed of the enemy as well as the

enemy’s associated color are determined. Finally, the

start time for the timer is set at the current time

of the clock function in the code.

*/
void snow::Difficulty()

LCD.Clear();

/*Determine the opponent based on the number of enemies the user has defeated*/

switch (numberhits){

case 0:

LCD.Clear();

LCD.SetFontColor(LCD.White);

LCD.WriteAt("STAGE 1", 120, 19);

LCD.WriteAt("Opponent:", 120, 67);

LCD.SetFontColor(CYAN);

LCD.WriteAt("Aidan", 120, 115);

LCD.SetFontColor(WHITE);

LCD.WriteAt("Location:", 120, 163);

LCD.SetFontColor(CYAN);

LCD.WriteAt("Taylor Tower", 120, 182);

Sleep(3.0);

speed = 2.0;

color = 0;

start_time = clock();

break;
case 1:

LCD.Clear();

LCD.SetFontColor(LCD.White);

LCD.WriteAt("STAGE 2", 120, 19);

LCD.WriteAt("Opponent:", 120, 67);

LCD.SetFontColor(YELLOW);

LCD.WriteAt("David", 120, 115);

LCD.SetFontColor(WHITE);

LCD.WriteAt("Location:", 120, 163);

LCD.SetFontColor(YELLOW);

LCD.WriteAt("Library on 18th", 120, 182);

Sleep(3.0);

speed = 1.5;

color = 1;

start_time = clock();

break;

case 2:

LCD.Clear();

LCD.SetFontColor(LCD.White);

LCD.WriteAt("STAGE 3", 120, 19);

LCD.WriteAt("Opponent:", 120, 67);

LCD.SetFontColor(GRAY);

LCD.WriteAt("Sophia", 120, 115);

LCD.SetFontColor(WHITE);
LCD.WriteAt("Location:", 120, 163);

LCD.SetFontColor(GRAY);

LCD.WriteAt("The Oval", 120, 182);

Sleep(3.0);

speed = 1.25;

color = 2;

start_time = clock();

break;

case 3:

LCD.Clear();

LCD.SetFontColor(LCD.White);

LCD.WriteAt("STAGE 4", 120, 19);

LCD.WriteAt("Opponent:", 120, 67);

LCD.SetFontColor(PURPLE);

LCD.WriteAt("Jay", 120, 115);

LCD.SetFontColor(WHITE);

LCD.WriteAt("Location:", 120, 163);

LCD.SetFontColor(PURPLE);

LCD.WriteAt("The Union", 120, 182);

Sleep(3.0);

speed = 1.0;

color = 3;

start_time = clock();

break;
case 4:

LCD.Clear();

LCD.SetFontColor(LCD.White);

LCD.WriteAt("STAGE 5", 120, 19);

LCD.WriteAt("Opponent:", 120, 67);

LCD.SetFontColor(GREEN);

LCD.WriteAt("Liz", 120, 115);

LCD.SetFontColor(WHITE);

LCD.WriteAt("Location:", 120, 163);

LCD.SetFontColor(GREEN);

LCD.WriteAt("Mirror Lake", 120, 182);

Sleep(3.0);

speed = .75;

color = 4;

start_time = clock();

break;

case 5:

LCD.Clear();

LCD.SetFontColor(LCD.White);

LCD.WriteAt("STAGE 6", 120, 19);

LCD.WriteAt("Opponent:", 120, 67);

LCD.SetFontColor(BLUE);

LCD.WriteAt("Simon", 120, 115);

LCD.SetFontColor(WHITE);
LCD.WriteAt("Location:", 120, 163);

LCD.SetFontColor(BLUE);

LCD.WriteAt("Thompson Library", 120, 182);

Sleep(3.0);

speed = 0.5;

color = 5;

start_time = clock();

break;

case 6:

LCD.Clear();

LCD.SetFontColor(LCD.White);

LCD.WriteAt("FINAL STAGE", 120, 19);

LCD.WriteAt("Opponent:", 120, 67);

LCD.SetFontColor(SCARLET);

LCD.WriteAt("Dr Parke", 120, 115);

LCD.SetFontColor(WHITE);

LCD.WriteAt("Location:", 120, 163);

LCD.SetFontColor(SCARLET);

LCD.WriteAt("The Horseshoe", 120, 182);

Sleep(3.0);

speed = 0.25;

color = 6;

start_time = clock();

break;
}

/*

DrawBoard() – Created by Michael Terveer

The DrawBoard() function creates the board on the screen

at the beginning of each level. Starting by clearing

the screen, the program then displays the location in

the bar on top based on which level and enemy is being

faced. The function then displays borders on the left,

right, and bottom of the screen before drawing the player

and their snowball. Additionally, the function resets

the number of teleports of the enemy right before the

next level begins.

*/

void snow::DrawBoard()

LCD.Clear();

//Enable loop in main to occur


hit=0;

/*Create Location Bar*/

LCD.SetDrawColor(WHITE);

LCD.FillRectangle(0, 0, 320, 27);

/*Determine Location of Battle*/

switch (color){

case 0:

LCD.SetFontColor(CYAN);

LCD.WriteAt("Taylor Tower", 110, 8);

break;

case 1:

LCD.SetFontColor(BLACK);

LCD.WriteAt("Library on 18th", 100, 8);

break;

case 2:

LCD.SetFontColor(GRAY);

LCD.WriteAt("The Oval", 120, 8);

break;

case 3:

LCD.SetFontColor(PURPLE);

LCD.WriteAt("The Union", 120, 8);


break;

case 4:

LCD.SetFontColor(GREEN);

LCD.WriteAt("Mirror Lake", 110, 8);

break;

case 5:

LCD.SetFontColor(BLUE);

LCD.WriteAt("Thompson Library", 100, 8);

break;

case 6:

LCD.SetFontColor(SCARLET);

LCD.WriteAt("The Horseshoe", 100, 8);

break;

/*Draw left border of board*/

int leftcounter = 0;

for (leftcounter; leftcounter < 12; leftcounter++){

int leftcircley = 31;

int leftrectangley = 35;

leftcircley = leftcircley + (leftcounter * 16);

leftrectangley = leftrectangley + (leftcounter * 16);


LCD.SetDrawColor(RED);

LCD.FillCircle(3, leftcircley, 4);

LCD.SetDrawColor(GRAY);

LCD.FillRectangle(0, leftrectangley, 8, 8);

/*Draw right border of board*/

int rightcounter = 0;

for (rightcounter; rightcounter < 12; rightcounter++){

int rightcircley = 31;

int rightrectangley = 35;

rightcircley = rightcircley + (rightcounter * 16);

rightrectangley = rightrectangley + (rightcounter * 16);

LCD.SetDrawColor(RED);

LCD.FillCircle(316, rightcircley, 4);

LCD.SetDrawColor(GRAY);

LCD.FillRectangle(312, rightrectangley, 8, 8);

/*Draw bottom left side border*/


int bottomcounter1 = 0;

for (bottomcounter1; bottomcounter1 < 7; bottomcounter1++){

int bottomcircle1x = 10;

bottomcircle1x = bottomcircle1x + (bottomcounter1 * 20);

LCD.SetDrawColor(WHITE);

LCD.FillCircle(bottomcircle1x, 229, 10);

/*Draw bottom right side border*/

int bottomcounter2 = 0;

for (bottomcounter2; bottomcounter2 < 7; bottomcounter2++){

int bottomcircle2x = 309;

bottomcircle2x = bottomcircle2x - (bottomcounter2 * 20);

LCD.SetDrawColor(WHITE);

LCD.FillCircle(bottomcircle2x, 229, 10);

/*Draw the player and their snowball*/

LCD.FillCircle(165, 211, 5);


LCD.SetDrawColor(BROWN);

LCD.FillCircle(160, 223, 7);

LCD.SetDrawColor(RED);

LCD.FillRectangle(158, 230, 5, 10);

/*Reset number of teleports for new enemy*/

numberOfTeleport=0;

/*

Timer() – Created by Austin Stewart

The Timer() function uses the clock function to determine

the time elapsed by the program since its beginning. The

timer sets a variable equal to the time outputted by the

clock function, then sets to another variable the time

difference between this value and the start value of the

function. This value must be divided by the constant

CLOCKS_PER_SECOND to produce a value in seconds. This

value is then translated so that it counts down, and

that is the value printed to the screen as each level

runs.

*/
void snow::Timer(){

int e_time, t_time;

// Run forever

e_time = clock();

t_time = (e_time-start_time)/CLOCKS_PER_SEC;

print_time = 32 - t_time;

LCD.SetDrawColor(LCD.White);

LCD.FillRectangle(0,0, 70, 27);

LCD.SetDrawColor(LCD.Black);

LCD.WriteAt(print_time, 10, 10);

/*

Opponent() – Created by Austin Stewart and Michael Terveer

The Opponent() function is used to display and move the

appropriate opponent during each level. The inputs to

the function are the color of the opponent based on the

level and the speed of the opponent. The function begins

by erasing the enemy’s previous position unless it has


not been displayed yet. Then, it generates a random

integer to determine where the enemy appears, determines

the correct enemy color, and draws the enemy at the

random position. It then waits for a period, based on

the speed of the opponent, for the user to touch the

screen for where the snowball should be thrown. Finally,

it increments the number of times the enemy has

teleported.

*/

void snow::Opponent()

/*Get rid of enemy at previous position if not first time*/

if (numberOfTeleport != 0)

LCD.SetDrawColor(BLACK);

LCD.FillCircle(xcoord, ycoord, 7);

LCD.FillRectangle(xcoord-2, ycoord+7, 5, 10);

/*Generate a Random x-coordinate between 0 and 289*/

xcoord = (RandInt() % 289);

/*Offset by 8 so in center of screen*/


xcoord = xcoord + 15;

/*Generate a Random y-coordinate between 0 and 154*/

ycoord = (RandInt() % 154);

/*Offset by 28 so in center of screen*/

ycoord = ycoord + 35;

/*Choose color of enemy*/

switch (color){

case 0:

LCD.SetDrawColor(CYAN);

break;

case 1:

LCD.SetDrawColor(YELLOW);

break;

case 2:

LCD.SetDrawColor(GRAY);

break;

case 3:

LCD.SetDrawColor(PURPLE);

break;

case 4:

LCD.SetDrawColor(GREEN);
break;

case 5:

LCD.SetDrawColor(BLUE);

break;

case 6:

LCD.SetDrawColor(SCARLET);

break;

//Clear touch buffer right before enemy is drawn

LCD.ClearBuffer();

//Draw enemy

LCD.FillRectangle(xcoord-2, ycoord+7, 5, 10);

LCD.SetDrawColor(BROWN);

LCD.FillCircle(xcoord, ycoord, 7);

/*Give user chance to hit target*/

Sleep(speed);

//Wait for user touch and store point at aimx and aimy

if(LCD.Touch(&aimx,&aimy)){

throwball=1;
snowballsThrown++;

else {

throwball=0;

/*Increment number of times enemy has teleported in level*/

numberOfTeleport++;

/*

Throwsnow() – Created by Will Terrell

The Throwsnow() function begins by determine if the

location touched by the user us within the hitbox for

the enemy. If it is, the function increments the number

of hits by 1 and sets a variable “hit” equal to 1 to

create a sleep period later in the function for the

transition to the next level. Regardless if a hit is

registered, the function creates a snowball at the

starting position before drawing a marker where the

snowball will end up (where the screen was touched).

Next, the function calculates the velocity of the


snowball in the x and y directions based on the difference

between the snowball’s initial position and the position

of the user’s touch. Then, the function creates the

motion of the snowball traveling to its desired location

before displaying the snowball at the desired location.

Combining all these operations displays the snowball

traveling from Brutus’ hand to the desired location as

well as registering a hit and moving onto the next level

if the touch is in the same relative location as the enemy.

*/

void snow::Throwsnow(){

int startx=165, starty=211, velocity=50, radius=5;

int xPosition , yPosition, xDifference, yDifference;

float i, distance, timeForDistance, xVelocity, yVelocity;

//Determine if snowball hit enemy

if (abs(aimx - xcoord) <= 10 && abs(aimy - ycoord) <= 20){

numberhits++;

hit=1;

LCD.SetFontColor(DARKRED);

LCD.WriteAt("HIT!", 145,120);

}
//Create snowball at starting position

LCD.FillCircle(startx, starty, radius);

//Define x and y position of snowball starting at starting position

xPosition=startx;

yPosition=starty;

// Draw circle where snowball where end up

LCD.DrawCircle(aimx,aimy,radius);

LCD.DrawHorizontalLine(aimy, aimx-11, aimx+9);

LCD.DrawVerticalLine(aimx, aimy-11, aimy+9);

/*

Calculating the snowballs velocity in x and y direction

*/

//Calculate the difference between the user's touch and snowball starting position

xDifference = aimx-startx;

yDifference = aimy-starty;

//Calculate distance with Pythagorean's theorem


distance = pow( (pow(abs(xDifference), 2) + pow(abs(yDifference), 2)) , .5);

//Calculate the time it will take the snowball to go the distance

//based off of the velocity

timeForDistance = distance / velocity;

//Calculate the necessary velocities for the x and y directions

xVelocity = xDifference / timeForDistance;

yVelocity = yDifference / timeForDistance;

/*

Moving the snowball

*/

i=0;

//Move the snowball until it lines up with the user's touch

do

Sleep(.00005);
//Color the screen black where the snowball used to be

LCD.SetDrawColor(GRAY);

LCD.FillCircle(xPosition,yPosition,radius);

//Calculate the new position of the snowball

xPosition=startx + i*xVelocity;

yPosition=starty + i*yVelocity;

//Draw the snowball in the new position

LCD.SetDrawColor(WHITE);

LCD.FillCircle(xPosition, yPosition, radius);

i+=.25;

}while (yPosition > aimy);

/*

Making the final snowball match the user's touch

*/

Sleep(.00005);
//Color the screen black where the snowball used to be

LCD.SetDrawColor(GRAY);

LCD.FillCircle(aimx,aimy,15);

//Draw the snowball in the new position

LCD.SetDrawColor(WHITE);

LCD.FillCircle(aimx, aimy, radius);

if (hit == 1){

Sleep(.75);

/*

Showresults() – Created by Austin Stewart

The Showresults() function is run after an iteration of

the game has concluded. If the player has defeated all

the enemies, it displays a congratulations message as

well as a continuation of the story. Otherwise, it


displays an animation of a snowball being through at

the screen before displaying that the user lost as well

as a different continuation of the story. After

displaying these messages, the function waits for the

user to touch the screen before displaying the single

game statistics.

*/

void snow::Showresults()

int i, c, d;

LCD.Clear();

LCD.ClearBuffer();

//Results for is user wins

if (numberhits == 7 ){

bossesbeat = 1;

LCD.SetDrawColor(LCD.Green);

for(i=0;i<23;i++){

LCD.FillRectangle(0, 0, 320, 240);

Sleep(.05);

Sleep(.5);
LCD.SetFontColor(BLACK);

LCD.WriteLine("");

LCD.WriteLine(" Dr. Parke has been defeated!");

LCD.WriteLine("");

LCD.WriteLine(" The FEH Teaching Staff");

LCD.WriteLine(" was thrown into the dungeons");

LCD.WriteLine("");

LCD.WriteLine(" And forced to grade lab reports");

LCD.WriteLine(" for the rest of their lives!");

//Wait for users touch to go to statistics

LCD.ClearBuffer();

while (!LCD.Touch(&c, &d))

LCD.WriteAt("Click anywhere to see statistics", 40, 220);

Sleep(1.0);

LCD.FillRectangle(20,210,300,30);

Sleep(1.0);

//Results if user loses

else{

LCD.SetDrawColor(LCD.White);

for(i=0;i<10;i++){
LCD.FillCircle(160, 120, 12*i);

Sleep(.05);

Sleep(.35);

LCD.SetDrawColor(LCD.Red);

for(i=0;i<23;i++){

LCD.FillRectangle(0, 0, 320, 10*i);

Sleep(.05);

LCD.FillRectangle(0, 0, 320, 240);

LCD.SetFontColor(BLACK);

LCD.WriteLine("");

LCD.WriteLine(" Brutus was hit!");

LCD.WriteLine("");

LCD.WriteLine(" The FEH Teaching Staff is unstoppable");

LCD.WriteLine("");

LCD.WriteLine(" Dr. Parke and his TA's");

LCD.WriteLine(" now terrorize campus with...");

Sleep(3.0);

LCD.FillRectangle(0, 0, 320, 240);

LCD.WriteAt("EVIL CATS!", 120, 115);

//Wait for users touch to go to statistics

LCD.ClearBuffer();
while (!LCD.Touch(&c, &d))

LCD.WriteAt("Click anywhere to see statistics", 40, 220);

Sleep(1.0);

LCD.FillRectangle(20,210,300,30);

Sleep(1.0);

You might also like