Professional Documents
Culture Documents
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;
float start_time;
int print_time=30;
int throwball;
int hit=0;
int numberOfTeleport=0;
float snowballsThrown=0.0;
int t_time;
float timeplayed = 0;
int bossesbeat = 0;
};
int main()
while (1)
snow1.Showmenu();
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();
{
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
snow1.Difficulty();
snow1.DrawBoard();
snow1.Timer();
//Loop while timer is still going and user hasn't hit anything
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;
/*
The Showmenu() function displays the menu for the game when
Brutus and his enemies. The function also draws the boxes
*/
void snow::Showmenu()
/*Create a while loop so the user can return to the main menu*/
numberhits = 0;
LCD.Clear();
/*
*/
LCD.SetFontColor(WHITE);
LCD.WriteAt("SN",190,1);
LCD.SetFontColor(SCARLET);
LCD.WriteAt("OSU",212,1);
int leftcounter = 0;
LCD.SetDrawColor(SCARLET);
LCD.SetDrawColor(GRAY);
int rightcounter = 0;
int rightrectangley = 0;
LCD.SetDrawColor(SCARLET);
LCD.SetDrawColor(GRAY);
int bottomcounter1 = 0;
LCD.SetDrawColor(WHITE);
int bottomcounter2 = 0;
LCD.SetDrawColor(WHITE);
LCD.SetDrawColor(BROWN);
LCD.SetDrawColor(SCARLET);
/*
*/
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.SetDrawColor(PURPLE);
LCD.SetDrawColor(BROWN);
LCD.SetDrawColor(SKYBLUE);
LCD.SetDrawColor(GREEN);
LCD.SetDrawColor(BROWN);
LCD.SetDrawColor(BLUE);
LCD.SetDrawColor(BROWN);
LCD.SetDrawColor(GRAY);
LCD.SetDrawColor(BROWN);
LCD.SetDrawColor(YELLOW);
LCD.SetFontColor(SCARLET);
LCD.SetDrawColor(BLACK);
LCD.ClearBuffer();
Sleep(1.0);
LCD.FillRectangle(60,116,200,26);
Sleep(1.0);
/*
*/
void snow::Showinstructions()
LCD.SetFontColor(WHITE);
LCD.WriteLine("INSTRUCTIONS");
LCD.SetDrawColor(BROWN);
LCD.SetDrawColor(BLUE);
Sleep(.5);
LCD.SetDrawColor(SCARLET);
LCD.DrawCircle(280,110,5);
/*Have the user click the screen to return to the main menu*/
int e, f;
LCD.SetDrawColor(BLACK);
LCD.ClearBuffer();
Sleep(1.0);
LCD.FillRectangle(20,210,300,30);
Sleep(1.0);
/*
The Showstats function shows the overall stats for the user
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.WriteLine(numberhits);
LCD.WriteLine(accuracy);
LCD.WriteLine(bossesbeat);
/*Have the user click the screen to return to the main menu*/
int c, d;
LCD.SetDrawColor(BLACK);
LCD.ClearBuffer();
Sleep(1.0);
LCD.FillRectangle(20,210,300,30);
Sleep(1.0);
/*
*/
void snow::Showcredits()
LCD.Clear();
LCD.SetFontColor(WHITE);
LCD.WriteLine("CREDITS");
LCD.WriteLine("Resources");
int g, h;
LCD.SetDrawColor(BLACK);
LCD.ClearBuffer();
Sleep(1.0);
LCD.FillRectangle(20,210,300,30);
Sleep(1.0);
/*
void snow::Backstory()
//Start Story
LCD.Clear();
LCD.SetFontColor(WHITE);
LCD.WriteLine(" ");
LCD.WriteLine(" ");
LCD.WriteLine(" ");
LCD.SetFontColor(GRAY);
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);
a += 20;
b += 20;
LCD.SetDrawColor(BROWN);
LCD.FillCircle(a, b, 7);
LCD.SetDrawColor(BLUE);
Sleep(.5);
LCD.SetDrawColor(BLACK);
LCD.FillCircle(a, b, 7);
}
//Wait 1 second before next message
Sleep(1.0);
LCD.Clear();
LCD.WriteLine(" ");
LCD.WriteLine(" ");
//Wait 6 sec
Sleep(6.0);
LCD.Clear();
LCD.WriteLine("");
LCD.WriteLine("");
LCD.WriteLine("");
LCD.WriteLine("");
Sleep(3.0);
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!");
Sleep(3.0);
//Add suspense
LCD.Clear();
Sleep(1.0);
LCD.WriteLine("");
LCD.WriteLine("");
LCD.WriteLine("");
LCD.WriteLine("");
LCD.WriteLine(" Presents:");
//Wait 4 sec
Sleep(4.0);
LCD.Clear();
{
int c, d;
c = RandInt()%310 + 5;
d = RandInt()%230 + 5;
DrawSnowflake(c,d);
Sleep(.5);
LCD.SetDrawColor(BLACK);
LCD.FillRectangle(70,100,180,50);
LCD.WriteLine("");
LCD.WriteLine("");
LCD.WriteLine("");
LCD.WriteLine("");
LCD.SetFontColor(LCD.Scarlet);
LCD.WriteLine(" SNOSU");
LCD.SetFontColor(LCD.Gray);
Sleep(4.0);
/*
game.
*/
LCD.SetDrawColor(WHITE);
/*
*/
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.SetFontColor(CYAN);
LCD.SetFontColor(WHITE);
LCD.SetFontColor(CYAN);
Sleep(3.0);
speed = 2.0;
color = 0;
start_time = clock();
break;
case 1:
LCD.Clear();
LCD.SetFontColor(LCD.White);
LCD.SetFontColor(YELLOW);
LCD.SetFontColor(WHITE);
LCD.SetFontColor(YELLOW);
Sleep(3.0);
speed = 1.5;
color = 1;
start_time = clock();
break;
case 2:
LCD.Clear();
LCD.SetFontColor(LCD.White);
LCD.SetFontColor(GRAY);
LCD.SetFontColor(WHITE);
LCD.WriteAt("Location:", 120, 163);
LCD.SetFontColor(GRAY);
Sleep(3.0);
speed = 1.25;
color = 2;
start_time = clock();
break;
case 3:
LCD.Clear();
LCD.SetFontColor(LCD.White);
LCD.SetFontColor(PURPLE);
LCD.SetFontColor(WHITE);
LCD.SetFontColor(PURPLE);
Sleep(3.0);
speed = 1.0;
color = 3;
start_time = clock();
break;
case 4:
LCD.Clear();
LCD.SetFontColor(LCD.White);
LCD.SetFontColor(GREEN);
LCD.SetFontColor(WHITE);
LCD.SetFontColor(GREEN);
Sleep(3.0);
speed = .75;
color = 4;
start_time = clock();
break;
case 5:
LCD.Clear();
LCD.SetFontColor(LCD.White);
LCD.SetFontColor(BLUE);
LCD.SetFontColor(WHITE);
LCD.WriteAt("Location:", 120, 163);
LCD.SetFontColor(BLUE);
Sleep(3.0);
speed = 0.5;
color = 5;
start_time = clock();
break;
case 6:
LCD.Clear();
LCD.SetFontColor(LCD.White);
LCD.SetFontColor(SCARLET);
LCD.SetFontColor(WHITE);
LCD.SetFontColor(SCARLET);
Sleep(3.0);
speed = 0.25;
color = 6;
start_time = clock();
break;
}
/*
*/
void snow::DrawBoard()
LCD.Clear();
LCD.SetDrawColor(WHITE);
switch (color){
case 0:
LCD.SetFontColor(CYAN);
break;
case 1:
LCD.SetFontColor(BLACK);
break;
case 2:
LCD.SetFontColor(GRAY);
break;
case 3:
LCD.SetFontColor(PURPLE);
case 4:
LCD.SetFontColor(GREEN);
break;
case 5:
LCD.SetFontColor(BLUE);
break;
case 6:
LCD.SetFontColor(SCARLET);
break;
int leftcounter = 0;
LCD.SetDrawColor(GRAY);
int rightcounter = 0;
LCD.SetDrawColor(RED);
LCD.SetDrawColor(GRAY);
LCD.SetDrawColor(WHITE);
int bottomcounter2 = 0;
LCD.SetDrawColor(WHITE);
LCD.SetDrawColor(RED);
numberOfTeleport=0;
/*
runs.
*/
void snow::Timer(){
// Run forever
e_time = clock();
t_time = (e_time-start_time)/CLOCKS_PER_SEC;
print_time = 32 - t_time;
LCD.SetDrawColor(LCD.White);
LCD.SetDrawColor(LCD.Black);
/*
teleported.
*/
void snow::Opponent()
if (numberOfTeleport != 0)
LCD.SetDrawColor(BLACK);
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;
LCD.ClearBuffer();
//Draw enemy
LCD.SetDrawColor(BROWN);
Sleep(speed);
//Wait for user touch and store point at aimx and aimy
if(LCD.Touch(&aimx,&aimy)){
throwball=1;
snowballsThrown++;
else {
throwball=0;
numberOfTeleport++;
/*
*/
void snow::Throwsnow(){
numberhits++;
hit=1;
LCD.SetFontColor(DARKRED);
LCD.WriteAt("HIT!", 145,120);
}
//Create snowball at starting position
xPosition=startx;
yPosition=starty;
LCD.DrawCircle(aimx,aimy,radius);
/*
*/
//Calculate the difference between the user's touch and snowball starting position
xDifference = aimx-startx;
yDifference = aimy-starty;
/*
*/
i=0;
do
Sleep(.00005);
//Color the screen black where the snowball used to be
LCD.SetDrawColor(GRAY);
LCD.FillCircle(xPosition,yPosition,radius);
xPosition=startx + i*xVelocity;
yPosition=starty + i*yVelocity;
LCD.SetDrawColor(WHITE);
i+=.25;
/*
*/
Sleep(.00005);
//Color the screen black where the snowball used to be
LCD.SetDrawColor(GRAY);
LCD.FillCircle(aimx,aimy,15);
LCD.SetDrawColor(WHITE);
if (hit == 1){
Sleep(.75);
/*
game statistics.
*/
void snow::Showresults()
int i, c, d;
LCD.Clear();
LCD.ClearBuffer();
if (numberhits == 7 ){
bossesbeat = 1;
LCD.SetDrawColor(LCD.Green);
for(i=0;i<23;i++){
Sleep(.05);
Sleep(.5);
LCD.SetFontColor(BLACK);
LCD.WriteLine("");
LCD.WriteLine("");
LCD.WriteLine("");
LCD.ClearBuffer();
Sleep(1.0);
LCD.FillRectangle(20,210,300,30);
Sleep(1.0);
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++){
Sleep(.05);
LCD.SetFontColor(BLACK);
LCD.WriteLine("");
LCD.WriteLine("");
LCD.WriteLine("");
Sleep(3.0);
LCD.ClearBuffer();
while (!LCD.Touch(&c, &d))
Sleep(1.0);
LCD.FillRectangle(20,210,300,30);
Sleep(1.0);