Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <cstdio>
- #include <time.h>
- #include <windows.h>
- #include <conio.h>
- using namespace std;
- string imie;
- int hpw, hpp=100;
- int obr1[3], obr2[3], obr3[3];
- int losenem;
- int x,y,z,atk;
- char wyb;
- void staty()
- {
- cout<<" "<<imie<<endl;
- cout<<"Zycie: "<<hpw<<" "<<"Zycie: "<<hpp<<endl;
- }
- void atak()
- {
- cout <<"1. Szybki atak (80% szans)"<<endl;
- cout <<"2. Atak podstawowy (50% szans)"<<endl;
- cout <<"3. Atak silowy (30% szans)"<<endl<<endl;
- }
- int main()
- {
- obr1[0]=15; obr1[1]=35; obr1[2]=70;
- cout<<"Wpisz imie: "; getline(cin,imie);
- cout << "Chwila, wybieram przeciwnika!" << endl<<endl<<endl;
- srand(time(NULL));
- losenem=rand()%1+1; //DAJ 3 SPOWROTEM
- cout<<"Losowanie... ";
- Sleep(2000);
- system("cls");
- //cout<<losenem;
- if(losenem==1){
- cout<<"Wylosowales wiesniaka (lvl 1)"<<endl;
- Sleep(1500);
- system("cls");
- hpw=60;
- while((hpp>0)&&(hpw>0)){
- cout<<endl<<"Wiesniak (lvl 1)"; staty();
- cout<<endl<<endl;
- atak();
- wyb=getch();
- if(hpp>0){
- switch(wyb){
- case '1':
- x=rand()%100+1;
- if(x<=80){
- hpw-=obr1[0];
- cout<<"Zadales "<<obr1[0]<<" obrazen"<<endl<<endl;
- Sleep(1000);
- }
- else{cout<<"Nie trafiles!"<<endl<<endl;
- Sleep(1000);
- }
- break;
- case '2':
- y=rand()%100+1;
- if(y<=50)
- {
- hpw-=obr1[1];
- cout<<"Zadales "<<obr1[1]<<" obrazen"<<endl<<endl;
- Sleep(1000);
- }
- else{cout<<"Nie trafiles!"<<endl<<endl;
- Sleep(1000);
- }
- break;
- case '3':
- z=rand()%100+1;
- if(z<=30)
- {
- hpw-=obr1[2];
- cout<<"Zadales "<<obr1[2]<<" obrazen"<<endl<<endl;
- Sleep(1000);
- }
- else{cout<<"Nie trafiles!"<<endl<<endl;
- Sleep(1000);
- }
- break;
- }
- }
- else if(hpp<=0){
- system("cls");
- cout<<"Przegrywasz walke!";
- getchar();getchar();
- exit(0);}
- if(hpw>0){
- cout<<"Wiesniak atakuje...";
- Sleep(1500);
- atk=rand()%3+1;
- if(atk==1){
- cout<<"Wiesniak uzyl szybkiego ataku "<<endl;
- Sleep(500);
- x=rand()%1+1; //ZMIEN NA 100
- if(x<=30){
- cout<<"i zadal Ci "<<obr1[0]<<" obrazen";
- hpp-=obr1[0];
- Sleep(1500);
- }
- else{cout<<"ale nie trafil"<<endl;
- Sleep(1500);}
- }
- else if(atk==2){
- cout<<"Wiesniak uzyl podstawowego ataku "<<endl;
- Sleep(500);
- y=rand()%1+1; //ZMIEN NA 100
- if(x<=20){
- cout<<"i zadal Ci "<<obr1[1]<<" obrazen";
- hpp-=obr1[1];
- Sleep(1500);
- }
- else{cout<<"ale nie trafil"<<endl;
- Sleep(1500);}
- }
- else if(atk==3){
- cout<<"Wiesniak uzyl silowego ataku "<<endl;
- Sleep(500);
- z=rand()%1+1; //ZMIEN NA 100
- if(x<=10){
- cout<<"i zadal Ci "<<obr1[2]<<" obrazen";
- hpp-=obr1[2];
- Sleep(1500);
- }
- else{cout<<"ale nie trafil"<<endl;
- Sleep(1500);}
- }
- system("cls");
- }
- else if (hpw<=0){
- system("cls");
- cout<<"Wygrywasz walke!";
- getchar();getchar();
- exit(0);}
- }
- }
- else if(losenem==2){
- cout<<"Wylosowales buntownika (lvl 2)"<<endl;
- Sleep(1500);
- hpw=100;
- cout<<endl<<"Buntownik (lvl 2)";staty();
- cout<<endl<<endl;
- atak();
- }
- else if(losenem==3){
- cout<<"Wylosowales rycerza (lvl 3)"<<endl;
- Sleep(1500);
- hpw=150;
- cout<<endl<<"Rycerz (lvl 3)";staty();
- cout<<endl<<endl;
- atak();
- }
- getchar();getchar();
- return 0;
- }
Add Comment
Please, Sign In to add comment