Quantcast
Channel: Forum Pasja Informatyki - Najnowsze pytania
Viewing all articles
Browse latest Browse all 65225

Prośba o ocenę 2 tyg. nauki [C++] na podstawie prostej gry tekstowej

$
0
0

Hejka! Od 2 tygodni regularnie uczę się C++
Wczoraj zacząłem tworzyć pseudo tekstowego RPG'a.

 

Ocenicie progres,składnie, estetyke,etc?

Wszelakie porady mile widziane :D

#include <iostream>
#include <cstdlib>
#include <time.h>
#include <conio.h>
using namespace std;

string hero;
string enemy;
//hero
int lvl_hero=1;
int hp_hero=25;
int hp_hero_max=25;
int hero_str=1;
int dmg_hero;
int hero_weapon;
//wybor/zmienne
int enemy_val;
int choice;
int stan=0;
//przeciwnik 1
int dmg_enemy_1;
int hp_enemy_1=10;
int hp_enemy_1_max=10;
//przeciwnik 2
int dmg_enemy_2;
int hp_enemy_2=15;
int hp_enemy_2_max=15;
//ekwipunek
int weapon_1;
string weapon_1_name = "Miecz [1-3 DMG]";
int weapon;
int potion=0;
int gold=0;
//statystyki
int tura=0;
int pojedynek=0;


int main(){

    cout << "Witaj poszukiwaczu przygod! Jak sie nazywasz?"<< endl;
    cin >>hero;
    cout << "Milo mi Cie poznac "<< hero << "!"<< endl;
    cout << endl;
    getch();

    cout << "Otrzymano "<<weapon_1_name << endl;
    cout << endl;
    weapon=1;


    do{
    cout << endl;
    cout <<"-------------------------"<<endl;
    cout << "1.Rozpocznij walke!"<< endl;
    cout << "2.Zobacz statystyki!"<< endl;
    cout << "3.Zobacz ekwipunek!"<< endl;
    cout << endl;
    cout << "4.Wypij miksture!(+10 HP)"<< "["<<potion<<"] szt."<<endl;
    cout << "5.Kup miksture! (50 Zlota)"<< endl;
    cout << "6.Zresetuj Gre"<< endl;
    cout << endl;
    cout <<"-------------------------"<<endl;
    cout <<"HP("<<hp_hero<<"/"<<hp_hero_max<<")"<<endl;
    cout <<"Zloto("<<gold<<")"<< endl;



    cout<<endl;
    cin>>choice;
    if(choice==1){
    stan=1;

        srand(time(NULL));
        enemy_val=rand()%2+1;
        if(enemy_val==1){

    do{

    cout << "Pojawia sie przeciwnik!"<< endl;
    cout << "-------------------------"<< endl;
    cout <<"To Dziki Pies! ("<<hp_enemy_1_max<< "HP)"<< endl;
    getch();
    do{
    cout << endl;
    srand(time(NULL));
        dmg_enemy_1=rand()%2+1;
    cout <<"Przeciwnik uderza! Zadano "<<dmg_enemy_1<<" obrazen!"<< endl;
    hp_hero = hp_hero-dmg_enemy_1;

    cout <<"Twoje HP: "<<hp_hero<< ""<< endl;
    cout <<"HP Przeciwnika: "<<hp_enemy_1<< ""<< endl;
    getch();
    cout << endl;

    srand(time(NULL));
    dmg_hero=rand()%3+1;
    cout <<"Atakujesz przeciwnika! Zadano "<<dmg_hero<<" obrazen!"<< endl;

    hp_enemy_1=hp_enemy_1-dmg_hero;
    cout <<"Twoje HP: "<<hp_hero<< ""<< endl;
    cout <<"HP Przeciwnika: "<<hp_enemy_1<< ""<< endl;
    tura++;
    getch();
    }while(hp_hero >0 && hp_enemy_1 >0);
    stan =0;
 if(hp_enemy_1<=0){
        gold += 50;
        cout << endl;
        cout<<"--------------------------"<<endl;
        cout << "Przeciwnik pokonany!"<< endl;
        cout<<"--------------------------"<<endl;
        cout<<endl;
        cout << "Otrzymano [Zloto 50]"<< endl;
        cout << endl;
        hp_enemy_1=hp_enemy_1_max;
    pojedynek++;



    }else{
    gold -= 50;
    cout << "Przegrales! Utracono[Zloto 50]"<< endl;

    }



    }while(stan==1);




    }if(enemy_val==2){
        do{

    cout << "Pojawia sie przeciwnik!"<< endl;
    cout << "-------------------------"<< endl;
    cout <<"To Ghul! ("<<hp_enemy_2_max<< "HP)"<< endl;
    getch();
    do{
        srand(time(NULL));
        dmg_enemy_2=rand()%4+1;
    cout << endl;

    cout <<"Przeciwnik uderza! Zadano "<<dmg_enemy_2<<" obrazen!"<< endl;
    hp_hero = hp_hero-dmg_enemy_2;


    cout <<"Twoje HP: "<<hp_hero<< ""<< endl;
    cout <<"HP Przeciwnika: "<<hp_enemy_2<< ""<< endl;
    getch();
    cout << endl;
    if(hp_hero <=0 || hp_enemy_2 <=0){

        break;
    }
    srand(time(NULL));
    dmg_hero=rand()%3+1;
    cout <<"Atakujesz przeciwnika! Zadano "<<dmg_hero<<" obrazen!"<< endl;

    hp_enemy_2=hp_enemy_2-dmg_hero;
    cout <<"Twoje HP: "<<hp_hero<< ""<< endl;
    cout <<"HP Przeciwnika: "<<hp_enemy_2<< ""<< endl;
    tura++;
    getch();
    }while(hp_hero >0 && hp_enemy_2 >0);
    stan =0;
 if(hp_enemy_2<=0){
        gold += 75;
        potion +=1;
        cout << endl;
        cout<<"--------------------------"<<endl;
        cout << "Przeciwnik pokonany!"<< endl;
        cout<<"--------------------------"<<endl;
        cout<<endl;
        cout << "Otrzymano [Zloto 75]"<< endl;
        cout << "Otrzymano [Mikstura]"<< endl;
        cout<<endl;
        hp_enemy_2=hp_enemy_2_max;

    pojedynek++;


    }else{
        if(gold>=50){
    gold -= 50;
        }
    cout<<endl;
    cout << "Przegrales! Utracono[Zloto 50]"<< endl;
    cout<<endl;




    }






    }while(stan==1);







    }

    }
    if(choice==2){
        stan=2;
        cout<<"Statystyki"<<endl;
        cout<<"-------------------"<<endl;
        cout<<"Imie: "<<hero<<endl;
        cout<<"Poziom Postaci("<<lvl_hero<<")"<< endl;
        cout<<"Obecne HP("<<hp_hero<< ")"<< endl;
        cout<<"Max HP("<<hp_hero_max<< ")"<< endl;
        cout<<"Liczba pojedynkow("<< pojedynek <<")"<< endl;
        cout<<"Liczba tur ("<<tura<<")"<<endl;
        cout<<"-------------------"<<endl;

        cout<< endl;
        cout<<"Kliknij dowolny przycisk aby powrocic do menu"<<endl;
        getch();
        stan=0;
        cout<<endl;



    }

    if(choice==3){
        stan=3;
        cout<<"Ekwipunek"<<endl;
        cout<<"-------------------"<<endl;
        cout<<"Bron("<<weapon_1_name<< ")"<< endl;
        cout<<"Mikstury ("<<potion<< ")"<< endl;
        cout<<"Zloto ("<<gold<<")"<<endl;
        cout<<"-------------------"<<endl;

        cout<< endl;
        cout<<"Kliknij dowolny przycisk aby powrocic do menu"<<endl;
        getch();
        stan=0;
        cout<<endl;

    }
    if(choice==4){
        if(hp_hero==hp_hero_max){}
        if(hp_hero_max-11<hp_hero){
        hp_hero+=(hp_hero_max-hp_hero);

        }else{

        cout << endl;
        cout << "Odnowiono 10HP!"<< endl;
        cout << endl;
        hp_hero +=10;
        cout <<"HP("<<hp_hero<<"/"<<hp_hero_max<<")"<<endl;


        stan=0;
        }



    }
    if(choice==5){
        if(gold<50){
            cout << "Niewystarczająca ilosc zlota!"<< endl;
            break;
        }
        gold-=50;
        potion+=1;


    }
    if(choice==6){
        tura=0;
        pojedynek=0;
        gold=0;
        hp_hero=hp_hero_max;
        potion=0;
    }






}while(stan==0);
return 0;
}

 


Viewing all articles
Browse latest Browse all 65225


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>