Skip to content
Permalink
Browse files
team mates work
  • Loading branch information
libanoca committed Mar 20, 2020
1 parent a618b26 commit ac14ca3c3fbb9b8dff41b94baa14ddc63704456b
Show file tree
Hide file tree
Showing 14 changed files with 324 additions and 0 deletions.
Binary file not shown.
@@ -0,0 +1,30 @@
#include "Enemy.h"
#include "Game.h"

Enemy::Enemy()
{
this->level = 1;
this->hpMax = level * 10;
this->hp = this->hpMax;
this->damageMin = level*4;
this->damageMax = level*5;
this->dropChance = rand() % 100;
this->defence = rand() % 100;
this->accuracy = rand() % 100;
}

Enemy::~Enemy()
{

}

std::string Enemy::getAsString() const
{
return "Level: " + std::to_string(this->level) + "\n" +
"Hp: " + std::to_string(this->hp) + " / " + std::to_string(this->hpMax) + "\n" +
"Damage: " + std::to_string(this->damageMin) + " - " + std::to_string(this->damageMax) + "\n" +
"Defence: " + std::to_string(this->defence) + "\n" +
"Accuracy: " + std::to_string(this->accuracy) + "\n" +
"Drop chance: " + std::to_string(this->dropChance) + "\n";
}

@@ -0,0 +1,28 @@
#pragma once
#include <stdlib.h>
#include <string>

class Enemy
{
private:
int level;
int hp;
int hpMax;
int damageMin;
int damageMax;
float dropChance;
int defence;
int accuracy;

public:
Enemy();
virtual ~Enemy();

inline bool isAlive() { return this->hp > 0; }
std::string getAsString() const;
inline void takeDamage(int damage) { this->hp -= damage; };
inline int getGamage() const { return rand() % this->damageMax - this->damageMin; }
inline int getExp() const { return level * 100; }

};

@@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
int hp = 15;
int enemyattack = 5;
string a;
cout << "Alien has " << hp << " health, every time you type 'Hit' it will drop by " << enemyattack << ".\n" << endl;
string Yes = "Hit";
while(true) // While typing 'Hit' it will minus the enemy attack value
{
cin >> a;
if (a == Yes)
{
hp -= enemyattack;
cout << "Alien now has " << hp << "HP left.\n\n";
if (hp==0) // When there is no Hp loop will break
{
break;
}
}
}
cout << "You have killed an enemy alien!" << endl;
}
@@ -0,0 +1,28 @@
#include <iostream>
using namespace std;

int main()
{
string input;
cout << "It was 1875, New Mexico Territory. A man named Brant were 4 miles away of his ranch taking care of his family horses when a big explosion happened in the city.\n" <<endl;
cout << "He quickly went back and saw everybody screaming, houses burning and some strange creatures shooting everything around.\n" <<endl;
cout << "The first thing he did was start looking for his family. After 5 minutes of searching he found out that his wife and 2 of his children were dead.\n " <<endl;
cout << "He wanted to take revenge and when he got outside he saw that there was nothing left - no strange creatures anymore, no cowboys just him.\n" << endl;
cout << "Brant was devastated. The only thing that was left, was sadness and hatred for these monsters.\n " << endl;
cout << "Type follow to begin the journey.\n" << endl;
cin >> input;

string Yes = "follow";

if (input == Yes) // If input is 'follow' then the story will continue
{
cout << "He picked himself up and vowed to the heavens that he shall not stop until every last one of those aliens is dead.\n" << endl;
cout << "After scavenging the remains of his city he got ready to follow the monsters trail.\n" << endl;
cout << "After traveling long and hard the trail led him to Area 51.\n" << endl;
}
else
{
cout << "You had one job... Start again...\n " << endl;
}

}
@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;

string hit = "hit"; //string hit to allow user to initiate the sequence.
int i = 3; // integer to measure health.
string health = "Health: "; //health string to print out how much health the user has.

int main()
{
cout << health << i << endl;
while ( i > 0); //loop so while i is greater than 0 the fight simulation will run until i is less than 0.
{
if ( cin >> hit);
{
cout << health << i-1;
}


}
}
Binary file not shown.
@@ -0,0 +1,51 @@
#include <iostream>
#include <string> //add strings to the code
#include <stdlib.h> // this and time.h and windows.h controls the speed of the printing of epilogue
#include <time.h>
#include <windows.h>
using namespace std;

int main() // main function
{
char epilogue[] = "Hello, and welcome to the game\n"
"--------------COWBOYS AND ALIENS--------------\n"
"In this beautiful world in the 1870's, you a young cowboy travelling around the country gunslinging and all are faced with an opponent your brain cannot comprehend.\n"
"Aliens..."
"Your mission is to kill all of the aliens and take out their leader before they destroy the west.\n""AND THE WORLD.\n"; // introduction epilogue.

for (int n = 0; n < sizeof(epilogue); n++) // this makes the epilogue appear letter by letter.
{
cout << epilogue[n];
Sleep(100); //controls the speed that the epilogue letters print.
// https://www.youtube.com/watch?v=TZ8LMeo99LI&t=523s - used speed of printing
}
int i = 1;
while (i<2)
{
cout << "so . . . will you defend earth?\n";
Sleep (100);
string choice; // choice string created.
cin >> choice;

if (choice == "yes" || choice == "yeah" || choice == "ok") // if choice is one of these it will respond.
{
cout << "ahh good, lets get this going then.\n";


}
else if (choice == "no") // else if statement for when input is no.
{
cout << "well that is really a shame, guess we'll just hope the world doesnt end . . . \n"
"press any key and enter to escape. \n";


}
else
{
return 0;
}


}
}

Binary file not shown.
@@ -0,0 +1,10 @@
#include <iostream>
#include newHealth.cpp
using namespace std;

int main(display)
{
display.sethealth(3);
cout << "Health" << display.gethealth() << "lives" << endl;
return 0
}
Binary file not shown.
@@ -0,0 +1,39 @@
#include <iostream>
using namespace std;

int main()
{

string input; //input string so user can initiate simulation.
int i = 3;


cout << "health: " << i << endl; //prints out the health of user.

cin >> input;
string Yes = "hit"; //string hit to start fight simulation.
if ( input == Yes) //if statement to simulate the fighting changing i to j then to h to keep tally of how much health has been lost or kept.
{
cout << "health: " << i-1 << endl;
}
int j=i-1;
cin >> input;
if (input == Yes)
{
cout << "health: " << j-1 << endl;
}
int h=i-1;
cin >> input;
if (input == Yes)
{
cout << "health: " << h-1 << endl;
}
if (i==0) //if statement when i is equal to 0 so that it will tell the user they have died and see if they want to restart.
{
cout << "Game Over" << endl << "You have Died" << endl;
cout << "would you like to play again? " << endl;
string okay = "yes";
cin >> input;

}
}
Binary file not shown.
@@ -0,0 +1,92 @@
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
#include <windows.h>


using namespace std;

int main()
{
string health = "Health: "; // string health to measure health of protagonist.
int hp = 3;
cout << health << hp << " "; // integer hp to keep tally of users health.

string fight; // fight string to simulate the fight sequence
cin >> fight;
int randomMax = 10; //random function so to make the fighting simulation random. - used for reference:https://www.tutorialspoint.com/cplusplus-program-to-generate-random-number
srand(time(0));





if (fight == "hit") // if input is hit it will trigger the random function and if below 5, will reduce HP of user by. and other responses for above 5.
{
if (rand()%randomMax <= 5)
{
cout << "oh no! you've missed and lost a life :(" << endl;
cout << "Health: " << hp - 1 << endl;
}

if (rand()%randomMax >= 6)
{
cout << "nice, direct hit!" << endl;
cout << " Health: " << hp << " " << endl;
}
};
cin >> fight;
if(fight == "again") // same simulation again but with the word 'again' so that the function knows how many lives the user may have this has more if statements.
{
if (rand()%randomMax <= 5)
{
cout << "oh no! you've missed and lost a life :(" << endl;
cout << "Health: " << hp - 2 << endl;
}

if (rand()%randomMax >= 6)
{
if ( hp == 2 )
{
cout << "nice one champ" << endl;
cout << " Health: " << hp - 1 << " " << endl;
}
else
{
cout << "nice one champ" << endl;
cout << " Health: " << hp << " " << endl;
}
}
};
cin >> fight;
if (fight == "fire")
{
if(rand()%randomMax <=5)
{
cout << "Dang it you've died :(" << endl << "Health: " << hp - 3 << endl;
}
if (rand()%randomMax >=6)
{
if (hp == 3)
{
cout << "That was close!" << endl;
cout << "Health: " << hp << endl;
}
if (hp == 2)
{
cout << "nice dodge" << endl << "Health: " << hp - 1 << endl;
}
else
{
cout << "nice dodge!" << endl << "Health: " << hp - 2 << endl;
}
}
};
if (hp == 0) // if health is 0 then the game ends.
{
cout << "Game over" << endl << "You have Died :(" << endl << "To play again press r " << endl;
terminate;
}

}

0 comments on commit ac14ca3

Please sign in to comment.