Guest User

Untitled

a guest
Dec 19th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cstdio>
  4. #include <time.h>
  5. #include <windows.h>
  6. #include <conio.h>
  7.  
  8. using namespace std;
  9.  
  10. string imie;
  11. int hpw, hpp=100;
  12. int obr1[3], obr2[3], obr3[3];
  13. int losenem;
  14. int x,y,z,atk;
  15. char wyb;
  16.  
  17. void staty()
  18. {
  19.     cout<<"                   "<<imie<<endl;
  20.     cout<<"Zycie: "<<hpw<<"                         "<<"Zycie: "<<hpp<<endl;
  21. }
  22.  
  23. void atak()
  24. {
  25.     cout <<"1. Szybki atak (80% szans)"<<endl;
  26.     cout <<"2. Atak podstawowy (50% szans)"<<endl;
  27.     cout <<"3. Atak silowy (30% szans)"<<endl<<endl;
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. int main()
  36. {
  37.     obr1[0]=15; obr1[1]=35; obr1[2]=70;
  38.  
  39.  
  40.     cout<<"Wpisz imie: "; getline(cin,imie);
  41.     cout << "Chwila, wybieram przeciwnika!" << endl<<endl<<endl;
  42.     srand(time(NULL));
  43.     losenem=rand()%1+1; //DAJ 3 SPOWROTEM
  44.     cout<<"Losowanie... ";
  45.     Sleep(2000);
  46.     system("cls");
  47.         //cout<<losenem;
  48.     if(losenem==1){
  49.  
  50.  
  51.  
  52.  
  53.         cout<<"Wylosowales wiesniaka (lvl 1)"<<endl;
  54.         Sleep(1500);
  55.         system("cls");
  56.         hpw=60;
  57.  
  58.  
  59.  
  60.  
  61.  
  62.         while((hpp>0)&&(hpw>0)){
  63.  
  64.         cout<<endl<<"Wiesniak (lvl 1)"; staty();
  65.         cout<<endl<<endl;
  66.         atak();
  67.         wyb=getch();
  68.         if(hpp>0){
  69.  
  70.  
  71.  
  72.         switch(wyb){
  73.  
  74.  
  75.  
  76.             case '1':
  77.                 x=rand()%100+1;
  78.                 if(x<=80){
  79.                     hpw-=obr1[0];
  80.                     cout<<"Zadales "<<obr1[0]<<" obrazen"<<endl<<endl;
  81.                     Sleep(1000);
  82.                 }
  83.                 else{cout<<"Nie trafiles!"<<endl<<endl;
  84.                 Sleep(1000);
  85.                 }
  86.  
  87.  
  88.  
  89.  
  90.  
  91.         break;
  92.         case '2':
  93.                 y=rand()%100+1;
  94.                 if(y<=50)
  95.                 {
  96.                     hpw-=obr1[1];
  97.                     cout<<"Zadales "<<obr1[1]<<" obrazen"<<endl<<endl;
  98.                     Sleep(1000);
  99.                 }
  100.                 else{cout<<"Nie trafiles!"<<endl<<endl;
  101.                 Sleep(1000);
  102.                 }
  103.         break;
  104.  
  105.  
  106.  
  107.  
  108.  
  109.             case '3':
  110.                 z=rand()%100+1;
  111.                 if(z<=30)
  112.                 {
  113.                     hpw-=obr1[2];
  114.                     cout<<"Zadales "<<obr1[2]<<" obrazen"<<endl<<endl;
  115.                     Sleep(1000);
  116.                 }
  117.  
  118.                 else{cout<<"Nie trafiles!"<<endl<<endl;
  119.                 Sleep(1000);
  120.                 }
  121.                 break;
  122.                 }
  123.  
  124.             }
  125.  
  126.  
  127.            else if(hpp<=0){
  128.                     system("cls");
  129.  
  130.                 cout<<"Przegrywasz walke!";
  131.                 getchar();getchar();
  132.                 exit(0);}
  133.  
  134.  
  135.  
  136.  
  137.             if(hpw>0){
  138.  
  139.  
  140.  
  141.  
  142.  
  143. cout<<"Wiesniak atakuje...";
  144. Sleep(1500);
  145.   atk=rand()%3+1;
  146.  
  147.     if(atk==1){
  148.  
  149.  
  150.  
  151.         cout<<"Wiesniak uzyl szybkiego ataku "<<endl;
  152.         Sleep(500);
  153.             x=rand()%1+1; //ZMIEN NA 100
  154.             if(x<=30){
  155.                 cout<<"i zadal Ci "<<obr1[0]<<" obrazen";
  156.                 hpp-=obr1[0];
  157.                 Sleep(1500);
  158.             }
  159.  
  160.  
  161.             else{cout<<"ale nie trafil"<<endl;
  162.             Sleep(1500);}
  163.             }
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.     else if(atk==2){
  171.         cout<<"Wiesniak uzyl podstawowego ataku "<<endl;
  172.             Sleep(500);
  173.             y=rand()%1+1; //ZMIEN NA 100
  174.             if(x<=20){
  175.  
  176.  
  177.  
  178.  
  179.                 cout<<"i zadal Ci "<<obr1[1]<<" obrazen";
  180.                 hpp-=obr1[1];
  181.                 Sleep(1500);
  182.             }
  183.  
  184.  
  185.             else{cout<<"ale nie trafil"<<endl;
  186.             Sleep(1500);}
  187.             }
  188.  
  189.  
  190.     else if(atk==3){
  191.         cout<<"Wiesniak uzyl silowego ataku "<<endl;
  192.         Sleep(500);
  193.             z=rand()%1+1; //ZMIEN NA 100
  194.             if(x<=10){
  195.  
  196.  
  197.  
  198.                 cout<<"i zadal Ci "<<obr1[2]<<" obrazen";
  199.                 hpp-=obr1[2];
  200.                 Sleep(1500);
  201.             }
  202.  
  203.  
  204.  
  205.             else{cout<<"ale nie trafil"<<endl;
  206.             Sleep(1500);}
  207.             }
  208.  
  209.  
  210.  
  211.  
  212.         system("cls");
  213.             }
  214.  
  215.  
  216.  
  217.  
  218.             else if (hpw<=0){
  219.                 system("cls");
  220.  
  221.                 cout<<"Wygrywasz walke!";
  222.                 getchar();getchar();
  223.                 exit(0);}
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.   }
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.         }
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.     else if(losenem==2){
  259.         cout<<"Wylosowales buntownika (lvl 2)"<<endl;
  260.         Sleep(1500);
  261.         hpw=100;
  262.         cout<<endl<<"Buntownik (lvl 2)";staty();
  263.         cout<<endl<<endl;
  264.         atak();
  265.  
  266.  
  267.     }
  268.  
  269.  
  270.  
  271.  
  272.     else if(losenem==3){
  273.         cout<<"Wylosowales rycerza (lvl 3)"<<endl;
  274.         Sleep(1500);
  275.         hpw=150;
  276.         cout<<endl<<"Rycerz (lvl 3)";staty();
  277.         cout<<endl<<endl;
  278.         atak();
  279.  
  280.  
  281.  
  282.  
  283.  
  284.     }
  285.  
  286.  
  287.  
  288.  
  289.  
  290. getchar();getchar();
  291.     return 0;
  292. }
Add Comment
Please, Sign In to add comment