diff --git a/CowboysvAliens (2).zip b/CowboysvAliens (2).zip new file mode 100644 index 0000000..f37b247 Binary files /dev/null and b/CowboysvAliens (2).zip differ diff --git a/Gustes code/Enemy.cpp b/Gustes code/Enemy.cpp new file mode 100644 index 0000000..bf8a9fc --- /dev/null +++ b/Gustes code/Enemy.cpp @@ -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"; +} + diff --git a/Gustes code/Enemy.h b/Gustes code/Enemy.h new file mode 100644 index 0000000..14596b8 --- /dev/null +++ b/Gustes code/Enemy.h @@ -0,0 +1,28 @@ +#pragma once +#include +#include + +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; } + +}; + diff --git a/Gustes code/hp.cpp b/Gustes code/hp.cpp new file mode 100644 index 0000000..3d39f07 --- /dev/null +++ b/Gustes code/hp.cpp @@ -0,0 +1,26 @@ +#include +#include +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; +} diff --git a/Gustes code/main.cpp b/Gustes code/main.cpp new file mode 100644 index 0000000..e92e98f --- /dev/null +++ b/Gustes code/main.cpp @@ -0,0 +1,28 @@ +#include +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" <> 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; + } + +} diff --git a/Text based - lukes other code/health.cpp b/Text based - lukes other code/health.cpp new file mode 100644 index 0000000..f53e934 --- /dev/null +++ b/Text based - lukes other code/health.cpp @@ -0,0 +1,20 @@ +#include +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; + } + + + } +} diff --git a/Text based - lukes other code/health.exe b/Text based - lukes other code/health.exe new file mode 100644 index 0000000..882235e Binary files /dev/null and b/Text based - lukes other code/health.exe differ diff --git a/Text based - lukes other code/intro.cpp b/Text based - lukes other code/intro.cpp new file mode 100644 index 0000000..59e0c29 --- /dev/null +++ b/Text based - lukes other code/intro.cpp @@ -0,0 +1,51 @@ +#include +#include //add strings to the code +#include // this and time.h and windows.h controls the speed of the printing of epilogue +#include +#include +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; + } + + + } +} + diff --git a/Text based - lukes other code/intro.exe b/Text based - lukes other code/intro.exe new file mode 100644 index 0000000..fc5fcaf Binary files /dev/null and b/Text based - lukes other code/intro.exe differ diff --git a/Text based - lukes other code/main.cpp b/Text based - lukes other code/main.cpp new file mode 100644 index 0000000..a354d08 --- /dev/null +++ b/Text based - lukes other code/main.cpp @@ -0,0 +1,10 @@ +#include +#include newHealth.cpp +using namespace std; + +int main(display) +{ + display.sethealth(3); + cout << "Health" << display.gethealth() << "lives" << endl; + return 0 +} \ No newline at end of file diff --git a/Text based - lukes other code/main.exe b/Text based - lukes other code/main.exe new file mode 100644 index 0000000..96ceb6b Binary files /dev/null and b/Text based - lukes other code/main.exe differ diff --git a/Text based - lukes other code/yes.cpp b/Text based - lukes other code/yes.cpp new file mode 100644 index 0000000..6c69e96 --- /dev/null +++ b/Text based - lukes other code/yes.cpp @@ -0,0 +1,39 @@ +#include +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; + + } +} \ No newline at end of file diff --git a/Text based - lukes other code/yes.exe b/Text based - lukes other code/yes.exe new file mode 100644 index 0000000..acd001e Binary files /dev/null and b/Text based - lukes other code/yes.exe differ diff --git a/main code/newHealth.cpp b/main code/newHealth.cpp new file mode 100644 index 0000000..5d65171 --- /dev/null +++ b/main code/newHealth.cpp @@ -0,0 +1,92 @@ +#include +#include +#include +#include +#include + + +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; + } + +} \ No newline at end of file