hey there ! guys ! i am working to make a rpg game ! but i don't know why it is not working !
please someone ! can explain to me ! so that i can find out the proper solution as soon as possible ! This is my project and i have to submit and i have less then 2 days ! so please !
hey there ! guys ! i am working to make a rpg game ! but i don't know why it is not working !
please someone ! can explain to me ! so that i can find out the proper solution as soon as possible ! This is my project and i have to submit and i have less then 2 days ! so please !
My source code is given below :
Umm...It would help if you actually posted the source :P
Edit: you posted it right as I did, if you could please edit your post and put [code] before your code and [ /code] after your code (with out the space).
public :
person () {}
~person () {}
string get_name () {return name;}
};
class enemy : public person
{
private :
enum level {BANDIT,COMMANDER};
level badguy;
public :
enemy (int level=1);
int attack () ;
string get_name () {return name ;}
};
enemy :: enemy (int level)
{
if (level =1)
{
badguy=BANDIT;
name ="Bandit";
}
else
{
badguy =COMMANDER;
name = "Madara_Uchiha";
}
}
int enemy :: attack ()
{
srand (time(0));
if (badguy==BANDIT)
{
int attack = ((rand() %20 ) +1);
return attack;
}
else if (badguy==COMMANDER)
{
int attack = ((rand()%25 ) +1);
return attack;
}
}
class player : public person
{
public :
player ();
void set_person ();
enum weaponlevel1 { wood=1, Bronze, Silver,Steel };
weaponlevel1 sword;
int attack ();
void change_sword ();
};
void player :: change_sword ()
{
cout << "Now u have entered in new level so choice a new sword/weapon to complete the upcoming missions :" << endl;
cout << " select any one from these swords :) " << endl;
cout << " Bronze <B> Steel <S> Silver <L> " << endl;
char changed_sword;
cin >> changed_sword;
switch (changed_sword)
{
case 'B' :
sword = Bronze;
break;
case 'S' :
sword = Steel;
break;
case 'L' :
sword = Silver;
break;
default :
cout << " Sorry ! U have chossen wrong word :( " << endl;
break;
{
cout << "What move u would like to do against enemy ? " << endl;
cout << "Slash<S> Lunge <L> Stab <A>" << endl;
char choice;
cin >> choice;
if (sword==wood)
{
switch (choice)
{
case 'S' :
{
int attack = (rand () %20 ) +1;
return attack;
}
case 'L' :
{
int attack =(rand () %15 ) +1;
return attack;
}
case 'A' :
{
int attack = (rand () %13) +1;
return attack;
}
}
}
if (sword==Bronze)
{
switch (choice)
{
case 'S' :
{
int attack = (rand () %22 ) +1;
return attack;
}
case 'L' :
{
int attack =(rand () %18 ) +1;
return attack;
}
case 'A' :
{
int attack = (rand () %15) +1;
return attack;
}
}
}
if (sword==Silver)
{
switch (choice)
{
case 'S' :
{
int attack = (rand () %26 ) +1;
return attack;
}
case 'L' :
{
int attack =(rand () %10 ) +1;
return attack;
}
case 'A' :
{
int attack = (rand () %18) +1;
return attack;
}
}
}
else if (sword==Steel)
{
switch (choice)
{
case 'S' :
{
int attack = (rand () %28 ) +1;
return attack;
}
case 'L' :
{
int attack =(rand () %24 ) +1;
return attack;
}
case 'A' :
{
int attack = (rand () %20) +1;
return attack;
}
}
}
return 0;
}
void player :: set_person ()
{
cout <<"If u don't mind then i would like to ask a question before starting the game " << endl;
cout << "What is ur name :D " << endl;
cout << ":" << endl;
cin >> name ;
cout << "Thank u for ur name " << endl;
cout << "Now let's start the Adventure Mr." << name << endl;
}
player :: player ()
{
sword=wood;
}
void introduction ()
{
cout << "Assassin's creed : Livinghood" << endl;
cout << endl << endl << endl << endl << "To make this game various people have worked ! So all dedication goes upon them " <<endl;
cout << " U are humbly welcome here to try this game " << endl;
cout << "Pathc v1.02" << endl;
cout << " So u have to be hero and u have to save a village called reika"<< endl;
cout << " Now u are a part of reika (an imaginary world) " << endl;
cout << "Here few bandits and templars have taken leadership from this village" << endl;
cout << "So task is simple u have to fight hard and bring peace here" << endl;
cout << "But one thing " << "Before we started we have to know few things " << endl;
}
bool fight (player myplayer,enemy theenemy)
{
int player_health =100;
int enemy_health =100;
bool continue_fight =true;
while (continue_fight)
{
int player_attack = myplayer.attack ();
int enemy_attack = theenemy.attack ();
if ((player_health >0 ) && (enemy_health <=0) )
{
cout << "Congratulations ! U have won the fight !" <<endl;
cout << "Be ready for next stage " << endl;
return true ;
}
else if (( player_health <=0) && (enemy_health >0))
{
cout << "U have beein defeated by the enemy " << endl;
cout << "Better luck best time :( " << endl;
cout << "\n\n\n\n\n\n" << endl;
cout << "Would u like to continiue or u want to quite the game ? " << endl;
char choice;
cin >>choice;
if (choice)
{
int player_health =100;
int enemy_health =100;
continue ;
}
else
{
cout << " Thanks for being our part" << endl;
return false;
cout << "If u can guess correctly this word then u wiil be able to change ur weapon from wood to Bronze or steel or silver " << endl ;
cout << "Alrright ! Here u are ...let's begin ur task :) " << endl;
cout << " Make a gues ! What the word actually is ? " << endl;
bool loop = true;
while (loop)
{
cout << word << " " << endl;
string guess;
cin >> guess;
if ( guess==word)
{
cout << " You got me :P " << endl;
myplayer.change_sword ();
loop= false;
}
else
{
cout << "Come on ! It's not the big deal ! Keep trying " << endl;
{
player mp ;
enemy boss (30);
enemy t_enemy;
gameplay game = intro;
bool quit = false;
while ( quit = ! true )
{
if (game==intro)
{
introduction ();
mp.set_person ();
system ("cls");
game=Fight;
}
if (game==Fight)
{
cout << "We need to fight this bandit !! He is terorizing this area.So Let's show them the power :3 " << endl;
bool the_fight = fight (mp,t_enemy);
if (the_fight =false)
{
game =End;
}
else
{
game =puzzle;
}
}
if (game==puzzle)
{
puzzle_game(mp);
game =Fight_boss;
}
if (game =Fight_boss)
{
cout << " It is now time to fight with main villain of this operation ! " << endl;
cout <<"His name is " << boss.get_name () << endl;
cout << " Good luck : " << endl;
cout << "\n\n\n\n\n\n\n\n\n\n\n" <<endl;
cout << " Are u ready " << endl;
string blank;
cin >> blank;
system ("cls");
bool last_fight = fight (mp,boss);
if (last_fight ==false )
{
game =End;
}
else
{
cout << "Thanks soldier ! Thank u for saving us " << endl;
cout << " You saved us " << endl;
}
}
if (game==End)
{
quit =true ;
}
cout << "Thanks for playing and staying with us " << endl;
cout << "Now time to say good bye :( " << endl;