Advertisement
RicoHeartless

ZombieTrip alpha 0.1

Apr 23rd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <Windows.h>
  4. #include "posdots.h"
  5. #include "random.h"
  6.  
  7. using namespace std;
  8. int dest = 0, life = 100, food = 100, gas = 100, war = 100, koef = 1;
  9. void game();
  10. void fight();
  11. void anim();
  12. void loot();
  13. //                                                                                  STARTING    MENU
  14. void main(){
  15.    
  16.     int i(1);
  17.     char userChose, arrow[20]{};
  18.     do {
  19.         system("cls");
  20.         cout << "\t\t\t\t" << "Where do you want to go?\n\n\n\n\n" << endl;
  21.         cout << "\t\t\t\t" << arrow[1] << "1.Vynnyky;(EASY)" << endl;
  22.         cout << "\t\t\t\t" << arrow[2] << "2.Lviv;(MEDIUM)" << endl;
  23.         cout << "\t\t\t\t" << arrow[3] << "3.Sokilnyky; (HARD)" << endl;
  24.         userChose = _getch();
  25.         if (userChose == 's'&& i != 4){ arrow[i] = '>'; arrow[i - 1] = ' '; i++; }//                Система керування меню
  26.         else if (userChose == 's') { arrow[3] = ' '; i = 1; arrow[i] = '>'; i++; }
  27.                
  28.     }
  29.     while (userChose != 'f');
  30.     dest = i-1;
  31.     system("cls");
  32.         switch (dest){
  33.         case 1: {cout << "\n\n\n\n\n\t\t\t\t\t\tLET'S GO INTO VYNNYKY!" << endl; Sleep(1500); } break;
  34.         case 2: {cout << "\n\n\n\n\n\t\t\t\t\t\tLET'S GO INTO LVIV!" << endl; Sleep(1500); } break;
  35.         case 3: {cout << "\n\n\n\n\n\t\t\t\t\t\tLET'S GO INTO SOKILNYKY!" << endl; Sleep(1500); } break;
  36.         default: cout << "ERROR!" << endl;
  37.         }
  38.     game();
  39. }
  40. /*                                                                                   User interface;*/
  41. void game()
  42. {
  43.     char play;
  44.     for (int p(0); p < (dest + 1) * 10; p++){
  45.         system("cls");
  46.         int lostgas = 15, lostfood = random(10, 20);
  47.         if (p != 0){
  48.             if (gas - lostgas > 0){ gas = gas - lostgas; }
  49.             else if (gas - lostgas <= 0){ gas = 0; system("cls"); cout << "You have lost all gas!\n GAME OVER!"; exit(0); }
  50.             if (food - lostfood > 0){ food = food - lostfood; }
  51.             else if (food - lostfood <= 0){ food = 0; system("cls"); cout << "You have starved to death!\n GAME OVER!"; exit(0); }
  52.         }
  53.         cout << "xxxxxxxxxxxxxxxxxxx" << endl;
  54.         cout << "x    life:" << life << "     x" << endl;
  55.         cout << "x    food:" << food << "     x" << endl;
  56.         cout << "x     gas:" << gas << "     x" << endl;
  57.         cout << "x     war:" << war << "     x" << endl;
  58.         cout << "xxxxxxxxxxxxxxxxxxx" << endl; /*                                                   END OF INTERFACE*/
  59.         anim();// driving the road
  60.         cout << "\n\n\n\n\n\t\t\t\t\t\tYou have lost: " << lostgas << " gas and: " << lostfood << " food";
  61.         play = getch();
  62.         fight();
  63.     }
  64. }
  65. //                                                                  анімація їзди, на половині - запускається ф-ія loot();
  66.     void anim(){
  67.         char f[]{"                                                                                                         "};
  68.         for (int k(0); k <= strlen(f); k++){
  69.             cout << f[k];  cout << "       .--." << endl; if (k > 0) { curs({ 0 + k, 7 }); }
  70.             cout << f[k];  cout << " .----'   '--." << endl; if (k > 0) { curs({ 0 + k, 8 }); }
  71.             cout << f[k];  cout <<" '-()-----()-'" << endl; if (k > 0) { curs({ 0 + k, 9 }); }
  72.             Sleep(25);
  73.             curs({ 0+k, 6 });
  74.             if (k == strlen(f) / 2){
  75.                 loot(); system("cls");
  76.                 cout << "xxxxxxxxxxxxxxxxxxx" << endl;
  77.                 cout << "x    life:" << life << "     x" << endl;
  78.                 cout << "x    food:" << food << "     x" << endl;
  79.                 cout << "x     gas:" << gas << "     x" << endl;
  80.                 cout << "x     war:" << war << "     x" << endl;
  81.                 cout << "xxxxxxxxxxxxxxxxxxx" << endl;
  82.                 k = 58; }
  83.         }
  84.     }
  85. //                                                          Питає шо шукати, знаходить ранд число. Використовує функцію анімації dots();
  86.     void loot(){
  87.         int i(1), randloot(0);
  88.         char userChose, arrow[20]{};
  89.         do {
  90.             system("cls");
  91.             cout << "xxxxxxxxxxxxxxxxxxx" << endl;
  92.             cout << "x    life:" << life << "     x" << endl;
  93.             cout << "x    food:" << food << "     x" << endl;
  94.             cout << "x     gas:" << gas << "     x" << endl;
  95.             cout << "x     war:" << war << "     x" << endl;
  96.             cout << "xxxxxxxxxxxxxxxxxxx" << endl;
  97.             cout << "\t\t\t\t" << "What do you want to find?\n\n\n\n\n" << endl;
  98.             cout << "\t\t\t\t" << arrow[1] << "1.Bullets" << endl;
  99.             cout << "\t\t\t\t" << arrow[2] << "2.Aids" << endl;
  100.             cout << "\t\t\t\t" << arrow[3] << "3.Gas" << endl;
  101.             cout << "\t\t\t\t" << arrow[4] << "4.Food" << endl;
  102.             userChose = _getch();
  103.             if (userChose == 's'&& i != 5){ arrow[i] = '>'; arrow[i - 1] = ' '; i++; }
  104.             else if (userChose == 's') { arrow[4] = ' '; i = 1; arrow[i] = '>'; i++; }
  105.  
  106.         } while (userChose != 'f');
  107.         i--;
  108.         printf("\n");
  109.         switch (i){
  110.         case 1: {cout << "Looking for Bullets";  dots(5, 19, 17); randloot = random(10, (60 / dest)*koef); cout << "You found " << randloot << " Bullets"; if (war + randloot > 100){ war = 100; }
  111.                 else { war += randloot; }  Sleep(500); randloot = 0; } break;
  112.         case 2: {cout << "Looking for Aids"; dots(10, 16, 17); randloot = random(5, (30 / dest)*koef); cout << "You found " << randloot << " Aids"; if (life + randloot > 100){ life = 100; }
  113.                 else { life += randloot; } Sleep(500); randloot = 0; } break;
  114.         case 3: {cout << "Looking for Gas"; dots(1, 15, 17); randloot = random(10, (60 / dest)*koef); cout << "You found " << randloot << " Gas"; if (gas + randloot > 100){ gas = 100; }
  115.                 else { gas += randloot; } Sleep(500); randloot = 0; } break;
  116.         case 4: {cout << "Looking for Food"; dots(7, 16, 17); randloot = random(10, 40 * koef); cout << "You found " << randloot << " Food"; if (food + randloot > 100){ food = 100; }
  117.                 else { food += randloot; } Sleep(500); randloot = 0;} break;
  118.         }
  119.     }
  120.     void fight(){
  121.         int enemyType(0), winrounds(0), yScore(0), eScore(0), fighttype(0), i(1);
  122.         char userChose, arrow[20]{}; //0 - zombies, 1 - humans;
  123.         enemyType = random(0, 1);
  124.         do {
  125.             system("cls");
  126.             cout << "\t\t\t\t" << "What type of fight do you prefer?\n\n\n\n\n" << endl;
  127.             cout << "\t\t\t\t" << arrow[1] << "1.Passive (Nothing changes)" << endl;
  128.             cout << "\t\t\t\t" << arrow[2] << "2.Aggressive (full gas, if you win atleast 2 rounds!)" << endl;
  129.             cout << "\t\t\t\t" << arrow[3] << "3.Stealth (full life, if you win atleast 2 rounds!" << endl;
  130.             userChose = _getch();
  131.             if (userChose == 's'&& i != 4){ arrow[i] = '>'; arrow[i - 1] = ' '; i++; }//                Система керування меню
  132.             else if (userChose == 's') { arrow[3] = ' '; i = 1; arrow[i] = '>'; i++; }
  133.  
  134.         } while (userChose != 'f');
  135.         fighttype = i - 1;
  136.         if (enemyType == 0){//humans
  137.             cout << "FIGHT AGAINST HUMANS!" << endl; Sleep(200);
  138.             for (int i(0); i <= 2; i++){
  139.                 int extraloot = random(10, 30);
  140.                 yScore = random(0, 10) - (2 * fighttype); if (yScore < 0) yScore = 0;
  141.                 eScore = random(0, 10) - (1 * koef); if (eScore < 0) eScore = 0;
  142.                 if (yScore > eScore){ winrounds += 1; cout << "You have won round!" << endl; Sleep(1400); }
  143.                 else if (yScore < eScore) { cout << "You have loose round! You have lost:" << extraloot << " life" << endl; Sleep(1400); if (life - extraloot <= 0){ life = 0; } else life -= extraloot; }
  144.                 else if (yScore == eScore) { cout << "DRAW! You have found extra loot:" << extraloot << "bullets!" << endl; Sleep(1400); if (war + extraloot >= 100){ war = 100; } else war += extraloot; }
  145.             }
  146.         }
  147.         else {//zombies
  148.             cout << "FIGHT AGAINST ZOMBIES!" << endl; Sleep(200);
  149.             for (int i(0); i <= 2; i++){
  150.                 int extraloot = random(10, 20);
  151.                 yScore = random(0, 10) - (2 * dest); if (yScore < 0) yScore = 0;
  152.                 eScore = random(0, 10) - (1 * koef); if (eScore < 0) eScore = 0;
  153.                 if (yScore > eScore){ winrounds += 1; cout << "You have won round!" << endl; Sleep(1400); }
  154.                 else if (yScore < eScore) { cout << "You have loose round! You have lost:" << extraloot << " life" << endl; Sleep(1400); if ((life - extraloot) <= 0){ life = 0; } else life = life - extraloot; }
  155.                 else if (yScore == eScore) {cout << "DRAW! You have found extra loot:" << extraloot << "bullets!" << endl; Sleep(1400); if (war + extraloot >= 100){ war = 100; } else war += extraloot; }
  156.                 }
  157.             }
  158.         if (fighttype == 2 && winrounds >= 2){ cout << "You have won 2 rounds! Full gas!" << endl; gas = 100; winrounds = 0; }
  159.         else if (fighttype == 3 && winrounds >= 2){ cout << "You have won 2 rounds! Full Health!" << endl; life = 100; winrounds; }
  160.         if (life == 0){ cout << "GAME OVER!" << endl; exit(0); }
  161.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement