Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string>
- #include <vector>
- #include <iomanip>
- #include <thread>
- #include <chrono>
- #include <windows.h>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- int lives = 3;
- void SetColor(int value) {
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), value);
- }
- string MainMenu() {
- string quit;
- int i;
- cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
- for (i = 0; i < 11; i++) {
- cout << "|" << setw(59) << "|" << endl;
- }
- cout << "|" << setw(10) << " ";
- SetColor(2);
- cout << R"(|\/| _ _ __|_ _ _ |~) _ _|__|_| _ )";
- SetColor(15);
- cout << setw(11) << "|" << endl;
- cout << "|" << setw(10) << " ";
- SetColor(2);
- cout << R"(| |(_)| |_\ | (/_| |_)(_| | | |(/_)";
- SetColor(15);
- cout << setw(11) << "|" << endl;
- cout << "|" << setw(59) << "|" << endl;
- cout << "|" << setw(38) << "A Game Created By:" << setw(21) << "|" << endl;
- cout << "|" << setw(45) << "Donald Draper and Jensen Tucker" << setw(14) << "|" << endl;
- for (i = 0; i < 8; i++) {
- cout << "|" << setw(59) << "|" << endl;
- }
- cout << "|" << setw(5) << "Type 'Start' to begin, Type 'Quit' to exit." << setw(16) << "|" << endl;
- cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl << endl;
- cin >> quit;
- return quit;
- }
- void ClearScreen()
- {
- cout << string(100, '\n');
- }
- void draw1() {
- SetColor(4);
- cout << endl;
- cout << R"( __ _ )" << endl;
- cout << R"( _/ \ _(\(o )" << endl;
- cout << R"( / \ / _ ^^^o )" << endl;
- cout << R"( / ! \/ ! '!!!v' )" << endl;
- cout << R"( ! ! \ _' ( \____ )" << endl;
- cout << R"( ! . \ _!\ \===^\) )" << endl;
- cout << R"( \ \_! / __! )" << endl;
- cout << R"( \! / \ )" << endl;
- cout << R"( (\_ _/ _\ ) )" << endl;
- cout << R"( \ ^^--^^ __-^ /(__ )" << endl;
- cout << R"( ^^----^^ "^--v' )" << endl;
- SetColor(15);
- }
- void draw2() {
- SetColor(5);
- cout << R"( .'''''. ..||..'''''''...)" << endl;
- cout << R"( / ##### \ : || ''.)" << endl;
- cout << R"( | ## # ## | :.||...''''''.... '.)" << endl;
- cout << R"( | # # # | || '''')" << endl;
- cout << R"( | ####### | . ||)" << endl;
- cout << R"( \ ##### / /| < _>)" << endl;
- cout << R"( \ ### / / |/ < _>)" << endl;
- cout << R"( ..'' ''... / | < _>)" << endl;
- cout << R"( .' / | /||)" << endl;
- cout << R"( ' |/ ||)" << endl;
- cout << R"( | | '.. | ||)" << endl;
- cout << R"( | | | '...'' ||)" << endl;
- cout << R"( | | | ||)" << endl;
- cout << R"( \ | | ||)" << endl;
- cout << R"( |\| | ||)" << endl;
- cout << R"( \| | ||)" << endl;
- cout << R"( | | ||)" << endl;
- cout << R"( | | ||)" << endl;
- cout << R"( | | ||)" << endl;
- cout << R"( __| |__ ||)" << endl;
- cout << R"( / '.........' \ ||)" << endl;
- cout << R"( '''''' '''''' ##)" << endl;
- SetColor(15);
- }
- int weapon;
- char role;
- int weaponChoice() {
- int weaponChoice;
- int Longsword, Battleaxe, Cutlass, Daggers, Crossbow, Longbow, Polearm;
- //Declaring Weapon Values weaponChoice
- Longsword = (rand() % 18) + 2; //1
- Battleaxe = (rand() % 12) + 4; //2
- Cutlass = (rand() % 8) + 6; //3
- Daggers = (rand() % 10) + 5; //4
- Crossbow = (rand() % 21); //5
- Longbow = (rand() % 10) + 5; //6
- Polearm = (rand() % 4) + 8; //7
- cout << "Choose your weapon" << endl << endl;
- cout << "Longsword, 2-20 Damage, +10 Damage with Warrior Class, press 1" << endl;
- cout << "Battleaxe, 4-16 Damage, + 4 Damage with Warrior Class, press 2" << endl;
- cout << "Cutlass, 6-14 Damage, + 5 Damage with Rogue Class, press 3" << endl;
- cout << "Daggers, 5-15 Damage, +5 Damage with Rogue Class, press 4" << endl;
- cout << "Crossbow, 0-20 Damage, +7 Damage if used with Hunter Class, press 5" << endl;
- cout << "Longbow, 5-15 Damage, +5 Damage if used with Hunter Class, press 6" << endl;
- cout << "Polearm, 8-12 Damage, non class specific, press 7" << endl;
- cout << endl;
- cin >> weaponChoice;
- if (weaponChoice == 1) {
- cout << "You chose the Longsword" << endl;
- }
- else if (weaponChoice == 2) {
- cout << "You chose the Battleaxe" << endl;
- }
- else if (weaponChoice == 3) {
- cout << "You chose the Cutlass" << endl;
- }
- else if (weaponChoice == 4) {
- cout << "You chose the Daggers " << endl;
- }
- else if (weaponChoice == 5) {
- cout << "You chose the Crossbow" << endl;
- }
- else if (weaponChoice == 6) {
- cout << "You chose the Longbow" << endl;
- }
- else if (weaponChoice == 7) {
- cout << "You chose the Polearm" << endl;
- }
- else {
- cout << "Invalid Command, please choose a Weapon";
- }
- return weaponChoice;
- }
- char roleChoice() {
- char roleChoice;
- // string Warrior, Rogue, Hunter;
- // Warrior = 1, Rogue = 2, Hunter = 3;
- cout << "Please pick a Role!" << endl << endl;
- // classChoice
- cout << "For Warrior, Press w" << endl; // 1
- cout << "For Rogue, Press r" << endl; // 2
- cout << "For Hunter, Press h" << endl; // 3
- cout << endl;
- cin >> roleChoice;
- cout << endl;
- if ((roleChoice == 'w') || (roleChoice == 'W')) {
- cout << "You chose to be a Warrior" << endl;
- }
- else if ((roleChoice == 'r') || (roleChoice == 'R')) {
- cout << "You chose to be a Rogue" << endl;
- }
- else if ((roleChoice == 'h') || (roleChoice == 'H')) {
- cout << "You chose to be a Hunter" << endl;
- }
- else {
- cout << "Invalid Command, please choose a Class";
- }
- return roleChoice;
- }
- int playerDamage() {
- int playerDamage;
- if ((role == 'w') || (role == 'W') && (weapon == 1)) {
- playerDamage = ((rand() % 18) + 2) + 10;
- }
- else if ((role == 'w') || (role == 'W') && (weapon == 2)) {
- playerDamage = ((rand() % 12) + 4) + 4;
- }
- else if ((role == 'r') || (role == 'R') && (weapon == 3)) {
- playerDamage = ((rand() % 12) + 4) + 4;
- }
- else if ((role == 'r') || (role == 'R') && (weapon == 4)) {
- playerDamage = ((rand() % 12) + 4) + 4;
- }
- else if ((role == 'h') || (role == 'H') && (weapon == 5)) {
- playerDamage = ((rand() % 12) + 4) + 4;
- }
- else if ((role == 'h') || (role == 'H') && (weapon == 6)) {
- playerDamage = ((rand() % 12) + 4) + 4;
- }
- else if (weapon == 1) {
- playerDamage = (rand() % 18) + 2;
- }
- else if (weapon == 2) {
- playerDamage = (rand() % 12) + 4;
- }
- else if (weapon == 3) {
- playerDamage = (rand() % 8) + 6;
- }
- else if (weapon == 4) {
- playerDamage = (rand() % 10) + 5;
- }
- else if (weapon == 5) {
- playerDamage = (rand() % 21);
- }
- else if (weapon == 6) {
- playerDamage = (rand() % 10) + 5;
- }
- else if (weapon == 7) {
- playerDamage = (rand() % 4) + 8;
- }
- return playerDamage;
- }
- void fight() {
- bool monster = true;
- int monsterHealth = 10, damage, enemyDamage;
- string action;
- ClearScreen();
- while (lives > 0 && monster == true) {
- draw1();
- cout << "A Dragon Has Appeared!" << endl;
- cout << "It's health is at " << monsterHealth << "." << endl;
- cout << "You Have " << lives << " Lives Left!" << endl;
- cin >> action;
- cout << endl;
- if (action == "fight" || action == "Fight") {
- srand(time(0));
- damage = playerDamage();
- cout << "You have done " << damage << " damage to the dragon!" << endl << endl;
- monsterHealth = monsterHealth - damage;
- if (monsterHealth < 1) {
- monster = false;
- }
- else {
- this_thread::sleep_for(chrono::seconds(1));
- cout << "The Dragon Swings!" << endl;
- enemyDamage = (rand() % 11);
- if (enemyDamage == 10) {
- cout << "The Dragon Hits You! You lose a health point!" << endl;
- lives--;
- }
- else {
- cout << "The Dragon Misses!" << endl;
- }
- this_thread::sleep_for(chrono::seconds(2));
- ClearScreen();
- }
- }
- else if (action == "quit" || action == "Quit") {
- lives = -1;
- }
- else {
- cout << "You have typed something that is not a command, please try again" << endl;
- this_thread::sleep_for(chrono::seconds(2));
- ClearScreen();
- }
- }
- if (lives == 0) {
- this_thread::sleep_for(chrono::seconds(1));
- cout << endl << "The dragon beat you. You Lose." << endl;
- this_thread::sleep_for(chrono::seconds(2));
- ClearScreen();
- }
- else if (monster == false) {
- this_thread::sleep_for(chrono::seconds(1));
- cout << endl << "You beat the dragon! You Win!" << endl;
- this_thread::sleep_for(chrono::seconds(2));
- ClearScreen();
- }
- else if (lives == -1) {
- this_thread::sleep_for(chrono::seconds(1));
- ClearScreen();
- }
- }
- void rules() {
- string start;
- int i;
- ClearScreen();
- cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
- for (i = 0; i < 11; i++) {
- cout << "|" << setw(59) << "|" << endl;
- }
- cout << "|" << setw(35) << "How to Play:" << setw(24) << "|" << endl;
- cout << "|" << setw(45) << "Choose your role and your weapon" << setw(14) << "|" << endl;
- cout << "|" << setw(39) << "Type 'Fight' to attack" << setw(20) << "|" << endl;
- cout << "|" << setw(45) << "Type 'Quit' to exit to the menu" << setw(14) << "|" << endl;
- for (i = 0; i < 10; i++) {
- cout << "|" << setw(59) << "|" << endl;
- }
- cout << "|" << setw(5) << "Type 'Start' to continue, Type 'Quit' to return to menu." << setw(3) << "|" << endl;
- cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl << endl;
- cin >> start;
- if (start == "Start" || start == "start") {
- role = roleChoice();
- weapon = weaponChoice();
- fight();
- }
- else if (start == "Quit" || start == "quit") {
- this_thread::sleep_for(chrono::seconds(1));
- ClearScreen();
- }
- else {
- this_thread::sleep_for(chrono::seconds(1));
- cout << "You have typed something that is not start or quit, please try again." << endl;
- this_thread::sleep_for(chrono::seconds(1));
- ClearScreen();
- }
- }
- int main() {
- string game = MainMenu();
- while (game != "Quit" && game != "quit") {
- if (game == "Start" || game == "start") {
- cout << "You Have Started The Game!" << endl;
- lives = 3;
- rules();
- }
- else {
- cout << "You have typed something that is not 'Quit' or 'Start', please try again" << endl << endl;
- this_thread::sleep_for(chrono::seconds(3));
- }
- game = MainMenu();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement