Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Alex Steib & Alex Jensen
- 5-20-2016
- CSP Hr 2
- Mr. Ferwerda
- Create Performance Task
- This program will run a short RPG in C++.
- */
- //----------------------------------------------------------------------------
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- using namespace std;
- //----------------------------------------------------------------------------
- // Function: titleandData
- // Purpose: Prints out a title screen & asks for the user for a name
- // Input: none
- // Output: the name entered by the user
- void titleandData(char name[100]);
- //----------------------------------------------------------------------------
- // Function: prologue
- // Purpose: Gives the user helpful background information on the story
- // Input: the name entered by the user
- // Output: none
- void prologue(char name[100]);
- //----------------------------------------------------------------------------
- // Function: stage1
- // Purpose: the first stage of the game
- // Inputs: the name of the user
- // Outputs: number of health potions & the stage number variable
- void stage1(char name[], int &health, int &stageNum);
- //-----------------------------------------------------------------------------
- // Function: basicenemy
- // Purpose: the code for the basic enemies
- // Inputs: none
- // Outputs: number of health potions gained from defeating the enemy
- void basicenemy(int &health);
- //-----------------------------------------------------------------------------
- // Function: healthNum
- // Purpose: the code that determines the number of health potions the player will earn from killing enemies
- // Inputs: the time it takes to kill the enemies
- // Outputs: number of health potions gained from defeating the enemy
- void healthNum(double TTK, int &health);
- //-----------------------------------------------------------------------------
- // Function: sword1
- // Purpose: the code for the basic sword
- // Inputs: none
- // Outputs: the sword level
- void sword1(int &swordLevel);
- //-----------------------------------------------------------------------------
- // Function: stage2
- // Purpose: the second stage of the game
- // Inputs: the stage number variable
- // Outputs: number of speed potions gained from defeating the enemy, number of health potions gained
- // and the stage number variable
- void stage2(int &stageNum, int &health, int &speed);
- //-----------------------------------------------------------------------------
- // Function: enemy2
- // Purpose: the code for the harder enemies
- // Inputs: the sword level
- // Outputs: number of speed potions gained from defeating the enemy
- void enemy2(int swordLevel, int &speed);
- //-----------------------------------------------------------------------------
- // Function: speedNum
- // Purpose: the code that determines the number of speed potions the player will earn from killing enemies
- // Inputs: the time to kill the enemies
- // Outputs: number of speed potions gained from defeating the enemy
- void speedNum(double TTK, int &speed);
- //-----------------------------------------------------------------------------
- // Function: sword2
- // Purpose: the code for the better sword
- // Inputs: none
- // Outputs: the sword level
- void sword2(int &swordLevel);
- //-----------------------------------------------------------------------------
- // Function: stage3
- // Purpose: the third stage of the game
- // Inputs: the stage number variable
- // Outputs: number of speed potions gained from defeating the enemy, number of health potions gained
- // and the stage number variable
- void stage2(int &stageNum, int &health);
- //-----------------------------------------------------------------------------
- // Function: enemy3
- // Purpose: the code for the hardest enemies
- // Inputs: the sword level
- // Outputs: number of speed potions gained from defeating the enemy & number of health potions gained from defeating the enemy
- void enemy2(int swordLevel, int &speed, int &health);
- //-----------------------------------------------------------------------------
- // Function: sword3
- // Purpose: the code for the best sword
- // Inputs: none
- // Outputs: the sword level
- void sword3(int &swordLevel);
- //-----------------------------------------------------------------------------
- // Function: finale
- // Purpose: the final stage of the game
- // Inputs: the stage number variable
- // Outputs: number of speed potions gained from defeating the enemy, number of health potions gained
- // and the stage number variable
- void finale(int &stageNum, int &health, int &speed);
- //-----------------------------------------------------------------------------
- // Functions: dragon
- // Purpose: the code for the dragon boss
- // Inputs: the sword level
- // Outputs: the stage number variable
- void enemy2(int swordLevel, int &stageNum);
- //-----------------------------------------------------------------------------
- // Function: epilogue
- // Purpose: the code for the epilogue
- // Inputs: the stage number variable
- // Outputs: none
- void epilogue(int stageNum);
- //-----------------------------------------------------------------------------
- //Function : Tutorial
- //Purpose basic tutorial of attack and health potions
- //Input : none
- //Output : none
- void tutorial();
- //-----------------------------------------------------------------------------
- //Function : First dungeon
- // Purpose : create first dungeon
- //Input : none
- // Output : none
- void firstdungeon (char name[]);
- //-----------------------------------------------------------------------------
- void main()
- {
- char name[100];
- titleandData(name);
- prologue(name);
- }
- //-----------------------------------------------------------------------------
- void titleandData(char name[])
- {
- srand(time(0));
- cout << "Welcome to INSERT RPG NAME HERE" << endl;
- cout << endl;
- cout << "Please enter your character’s name: ";
- cin >> name[24];
- }
- //-----------------------------------------------------------------------------
- void prologue(char name[])
- {
- cout << "Once upon a time, there once was a brave hero named " << name[24] << endl;
- cout << "Our hero was having a normal day until an evil dragon decided to destroy our hero’s home village. Now, " << name[24] << " must save the village from the terrors of the dragon. " << endl;
- system("pause");
- cout << " ___====-_ _-====___" << endl;
- cout << " __--^^^ // \\ ^^^--_" << endl;
- cout << " _-^ // ( ) \\ ^-_" << endl;
- cout << " - // |\^^/| \\ -" << endl;
- cout << " _/ // (0::0) \\ \_" << endl;
- cout << " / (( \\// )) \ " << endl;
- cout << " - \\ (oo) // -" << endl;
- cout << " - \\ / \/ \ // -" << endl;
- cout << " - \\/ \// -" << endl;
- cout << "/ /| /\ ( ) /\ |\ \ " << endl;
- cout << "|/ | /\_/\_/\_/ \_/\ ( /\ ) /\_/ \_/\_/\_/\ | \|" << endl;
- }
- //-----------------------------------------------------------------------------
- void tutorial()
- {
- //basicenemy();
- //healthpotion();
- }
- //-----------------------------------------------------------------------------
- void firstdungeon (char name[])
- {
- int chance;
- int x;
- //Tutorial for enemies and health
- for (x = 0; x < 15; x ++)
- {
- chance = (rand() % 3) + x;
- if (chance < 5)
- cout << "The path is clear" << endl;
- else if (chance < 8 && chance > 5)
- cout << "A health potion has appeared" << endl;
- //Healthpotion()
- else if (chance < 13)
- //basicenemy()
- cout << " A foe stands in your way" << endl;
- //Combat()
- if (x > 10)
- chance = (rand() % 5) + 4;
- if (chance < 5)
- cout << "The path is clear" << endl;
- else if (chance < 8 && chance > 5)
- cout << "A health potion has appeared" << endl;
- else if (chance < 13)
- //basicenemy()+
- cout << " A foe stands in your way" << endl;
- //Combat()
- }
- cout << "You have found the final enemy" << endl;
- system("pause");
- cout << " THE MIGHTY DRAGON!!! "<< endl;
- //Dragon()
- cout << " ___====-_ _-====___" << endl;
- cout << " __--^^^ // \\ ^^^--_" << endl;
- cout << " _-^ // ( ) \\ ^-_" << endl;
- cout << " - // |\^^/| \\ -" << endl;
- cout << " _/ // (0::0) \\ \_" << endl;
- cout << " / (( \\// )) \ " << endl;
- cout << " - \\ (oo) // -" << endl;
- cout << " - \\ / \/ \ // -" << endl;
- cout << " - \\/ \// -" << endl;
- cout << "/ /| /\ ( ) /\ |\ \ " << endl;
- cout << "|/ | /\_/\_/\_/ \_/\ ( /\ ) /\_/ \_/\_/\_/\ | \|" << endl;
- }
- void basicenemy(int &health)
- {
- // Variable Declarations
- int basichealth = 3; // health for the enemy
- int basicdamage = 2; // damage for the enemy
- int clock = 0; // "shot clock"
- int attack = 0; // used for attacks
- int counterattack = 0; // used for counterattacks
- int stage = 1; // stage number
- int hpots; // number of health potions
- for (int rounds = 0; rounds < 5; rounds++)
- {
- system("CLS");
- cout << "Here comes an enemy!" << endl;
- clock++;
- cout << "Enter 1 to attack!" << endl;
- cin >> attack;
- if ((attack == 1) && (clock <= 5))
- {
- basichealth = basichealth - 2;
- cout << "Direct hit! -2 health" << endl;
- if (basichealth < 0)
- {
- cout << "Your enemy is dead!" << endl;
- stage = stage + 1;
- hpots = rand() * 5;
- if (stage == 2)
- {
- stage2(stage, hpots);
- }
- }
- counterattack = rand() * 10;
- if (counterattack < 6)
- {
- health = health - 2;
- cout << "Your enemy counter-attacked you! -2 health" << endl;
- if (health < 0)
- {
- cout << "You're dead!" << endl;
- }
- }
- attack = 0;
- clock = 0;
- }
- if (clock > 5)
- {
- counterattack = rand() * 10;
- if (counterattack < 6)
- {
- health = health - 2;
- }
- clock = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement