Hello all
I would like to ask how to make a simple graphics for this txt based rpg I create . I was planning to make some via dark gdk . So my question would be if anyone would like to tell some basic sprite in dark gdk
below here is my game
#include<iostream>
#include<string>
#include<ctime>
#include<cstdlib>
using namespace std;
class player {
int getDamage( );
string getName( );
string getJob( );
public:
string p_name;
string p_job;
int potion;
int manaPotion;
int powerPotion;
int p_lvl;
int p_damage;
int p_magicDamage;
int p_powerDamage;
int p_life;
int p_mana;
int p_power;
int p_xp;
int p_gold;
int p_maxXp;
int p_maxLife;
int p_maxMana;
int p_maxPower;
player ( );
};
player :: player( ){
p_maxLife = 30;
p_lvl = 1;
p_maxXp = 2;
p_xp = 0;
p_gold = 10;
p_name = getName ( );
p_job = getJob ( );
p_life = p_maxLife;
p_damage = getDamage ( );
if ( p_job == "Warrior" ){
p_maxMana = 5;
p_maxPower = 10;
p_magicDamage = 5;
p_powerDamage = 10;
p_mana = p_maxMana;
p_power = p_maxPower;
}else if ( p_job == "Assasin" ){
p_maxMana = 7;
p_maxPower = 7;
p_magicDamage = 7;
p_powerDamage = 7;
p_mana = p_maxMana;
p_power = p_maxPower;
}else{
p_maxMana = 10;
p_maxPower = 5;
p_magicDamage = 10;
p_powerDamage = 5;
p_mana = p_maxMana;
p_power = p_maxPower;
}
}
string player::getName( ) {
system ( "cls" );
cout<<"\tJourney Txt Fighting Game\n\n"
<<"What is your name : ";
string name;
cin>>name;
system ( "pause" );
return name;
}
string player::getJob( ) {
int choice;
do{
system ( "cls" );
cout<<"\tJourney Txt Fighting Game\n\n"
<<"What job do you want :\n"
<<"[ 1 ] - Warrior\n"
<<"[ 2 ] - Assasin\n"
<<"[ 3 ] - Soolsa\n"
<<"Choice : ";
cin>>choice;
} while ( choice < 1 || choice > 3 );
system ( "pause" );
if ( choice == 1 ){
return "Warrior";
}else if ( choice == 2 ){
return "Assasin";
}else{
return "Soolsa";
}
}
int player::getDamage( ) {
srand ( time ( 0 ) );
int damage = rand ( ) % 5 + 1;
return damage;
}
class enemy {
int getDamage ( );
public :
enemy ( );
int e_damage;
int e_life;
int e_maxLife;
};
enemy ::enemy( ){
e_maxLife = 20;
e_life = e_maxLife;
e_damage = getDamage ( );
}
int enemy::getDamage( ) {
int damage;
if ( e_life <= 5 ) {
damage = 10;
}else {
srand ( time ( 0 ) );
damage = rand ( ) % 5 + 1;
}
return damage;
}
player hero;
enemy villain;
void menu ( );
string title ( );
void fight ( );
char switchTurn ( char turn );
int playerMove ( int &heroLife , int &heroDamage , int &enemyLife );
void run ( int &heroLife , int &enemyMaxLife );
int useItems ( int &heroLife , int &potion , int &manaPotion, int &powerPotion , int &mana , int &power );
int attack ( int &heroLife , int &mana , int &power , int &enemyLife );
int enemyMove ( int &heroLife , int enemyDamage );
void displayStatus (int &xp , int &gold , int &maxXp );
void displayHp( );
void shop ( int &gold , int &potion , int &manaPotion , int &powerPotion);
void check ( int &xp , int &maxXp , int &life , int &maxLife , int &mana , int &maxMana , int &power , int &maxPower );
int main ( ) {
menu ( );
cin.ignore ( cin.rdbuf ( ) ->in_avail ( ) + 1 );
return 0;
}
inline string title ( ){
return "\tJourney Txt Fighting Game\n\n";
}
void menu ( ){
int choice;
do {
system ( "cls" );
cout<<title ( )
<<"What do you want to do ? \n"
<<"[ 1 ] - fight an enemy\n"
<<"[ 2 ] - goto a shop\n"
<<"[ 3 ] - display character status\n"
<<"[ 4 ] - exit the game\n"
<<"Choice : ";
cin>>choice;
} while ( choice < 1 || choice > 4 );
switch ( choice ){
case 1 :
cout<<"Your are about to fight now an enemy \n";
system ( "pause" );
fight ( );
break;
case 2 :
cout<<"You are about to go in to a shop now\n";
system ( "pause" );
shop ( hero.p_gold , hero.potion , hero.manaPotion , hero.powerPotion );
break;
case 3 :
cout<<"Character info now loading.....\n";
system ( "pause" );
displayStatus ( hero.p_xp , hero.p_gold , hero.p_maxXp );
break;
case 4:
cout<<"Thanks for playing .......\n";
break;
}
}
void fight ( ){
char playerTurn = 'x';
char enemyTurn = 'o';
char turn = playerTurn;
int life;
int faint = 0;
do {
if ( turn == playerTurn ){
life = playerMove ( hero.p_life , hero.p_damage , villain.e_life );
turn = switchTurn ( turn );
}else {
life = enemyMove ( hero.p_life , villain.e_damage );
turn = switchTurn ( turn );
}
}while ( life > faint );
system ( "cls" );
cout<<title ( );
if ( hero.p_life <= 0 ){
cout<<"GAME OVER YOU HAVE BEEN DEFEATED.....\n"
<<"To play again please restart the game....\n";
system ( "pause" );
}else{
cout<<"CONGRATULATION YOU DEFEAT THE ENEMY......\n"
<<"you have loot 1 gold .\n";
check ( hero.p_xp , hero.p_maxXp , hero.p_life , hero.p_maxLife , hero.p_mana , hero.p_maxMana , hero.p_power , hero.p_maxPower );
villain.e_life = villain.e_maxLife ;
hero.p_gold = hero.p_gold + 1;
system ( "pause" );
menu ( );
}
}
char switchTurn ( char turn ) {
if ( turn == 'x')
return 'o';
else
return 'x';
}
int playerMove ( int &heroLife , int &heroDamage , int &enemyLife ) {
int move;
int life;
do{
system ( "cls" );
displayHp ( );
cout<<"What is your move ?\n"
<<"[ 1 ] - attack the enemy\n"
<<"[ 2 ] - use items\n"
<<"[ 3 ] - run \n"
<<"Choice : ";
cin>>move;
} while ( move < 1 || move > 3 );
switch ( move ) {
case 1 :
life = attack ( hero.p_life , hero.p_mana , hero.p_power , villain.e_life );
return life;
break;
case 2 :
life = useItems ( hero.p_life , hero.potion , hero.manaPotion , hero.powerPotion , hero.p_mana , hero.p_power );
return life;
break;
case 3 :
run ( hero.p_life , villain.e_maxLife );
return life;
break;
}
}
void run ( int &heroLife , int &enemyMaxLife) {
displayHp ( );
cout<<"Escaped safely ....\n";
hero.p_life = heroLife;
villain.e_life = enemyMaxLife;
menu ( );
}
int useItems ( int &heroLife , int &potion , int &manaPotion , int & powerPotion , int &mana , int &power ){
int choice;
do{
system ( "cls" );
cout<<title ( )
<<"Inventory : \n"
<<"[ 1 ] - potion "<<potion<<" pcs\n"
<<"[ 2 ] - mana potion "<<manaPotion<<" pcs\n"
<<"[ 3 ] - power potion "<<powerPotion<<" pcs\n"
<<"What do you want to use : ";
cin>>choice;
} while ( choice < 1 || choice > 3 );
switch ( choice ) {
case 1 :
if ( potion <= 0 ){
cout<<"Sorry out of stock\n";
system ( "pause" );
return heroLife;
}else{
cout<<"You have use a potion\n";
system ( "pause" );
heroLife = heroLife + 10;
potion--;
if ( heroLife > hero.p_maxLife ){
heroLife = hero.p_maxLife ;
return heroLife;
}else{
return heroLife;
}
}
break;
case 2:
if ( manaPotion <= 0 ){
cout<<"Sorry out of stock\n";
system ( "pause" );
return heroLife;
}else{
cout<<"You have use a mana potion\n";
system ( "pause" );
mana = mana + 10;
manaPotion--;
if (mana >hero.p_maxMana ){
mana = hero.p_maxMana ;
return heroLife;
}else{
return heroLife;
}
}
break;
case 3:
if ( powerPotion <= 0 ){
cout<<"Sorry out of stock\n";
system ( "pause" );
return heroLife;
}else{
cout<<"You have use a power potion\n";
system ( "pause" );
power = power + 10;
powerPotion--;
if (power > hero.p_maxPower ){
power = hero.p_maxPower ;
return heroLife;
}else{
return heroLife;
}
}
break;
}
}
int attack ( int & heroLife , int &mana , int &power , int &enemyLife ){
int choice;
do{
system ( "cls" );
cout<<title ( )
<<"what do you want to use ?\n"
<<"[ 1 ] - normal attack\n"
<<"[ 2 ] - magic attack\n"
<<"[ 3 ] - power attack\n"
<<"choice : ";
cin>>choice;
} while ( choice < 1 || choice > 3 );
switch ( choice ) {
case 1 :
cout<<"You have inflicted a normal damage of "<<hero.p_damage <<" to your enemy\n";
system ( "pause" );
enemyLife = enemyLife - hero.p_damage ;
return enemyLife;
break;
case 2 :
if ( mana <= 0 ){
cout<<"Sorry out of mana\n";
system ( "pause" );
return enemyLife;
}else {
cout<<"You have inflicted a magic damage of "<<hero.p_magicDamage <<" to your enemy\n";
system ( "pause" );
mana = mana - 1;
enemyLife = enemyLife - hero.p_magicDamage ;
return enemyLife;
}
break;
case 3:
if ( power <= 0 ){
cout<<"Sorry out of power\n";
system ( "pause" );
return enemyLife;
}else {
cout<<"You have inflicted a power damage of "<<hero.p_powerDamage <<" to your enemy\n";
system ( "pause" );
enemyLife = enemyLife - hero.p_powerDamage ;
power = power - 1;
return enemyLife;
}
break;
}
return enemyLife;
}
int enemyMove ( int &heroLife , int enemyDamage ){
system ( "cls" );
displayHp ( );
cout<<"The enemy inflicted damage of "<<enemyDamage<<" to your life.\n";
heroLife = heroLife - enemyDamage;
system ( "pause" );
return heroLife;
}
void displayStatus ( int &xp , int &gold , int & maxXp ){
system ( "cls" );
cout<<title ( )
<<"Player Status \n"
<<"Player Name : "<<hero.p_name <<endl
<<"Player Job : "<<hero.p_job <<endl
<<"Player lvl : "<<hero.p_lvl <<endl
<<"HP : "<<hero.p_life <<endl
<<"MANA : "<<hero.p_mana <<endl
<<"POWER : "<<hero.p_power <<endl
<<"\ncurrent Gold : "<<gold <<endl
<<"Exp : "<<xp <<endl
<<"Exp to lvl up : "<<maxXp <<endl;
system ( "pause" );
menu ( );
}
void displayHp ( ) {
system ( "cls" );
cout<<title ( )
<<"Player \n"
<<"HP : "<<hero.p_life <<endl
<<"MANA : "<<hero.p_mana <<endl
<<"POWER : "<<hero.p_power <<endl<<endl
<<"Enemy \n"
<<"HP : "<<villain.e_life <<endl<<endl<<endl;
}
void shop ( int &gold , int &potion , int &manaPotion , int &powerPotion ){
system ( "cls" );
int choice;
do {
cout<<title ( )
<<"Current gold : "<<gold<<endl
<<"what do you want to buy ?\n"
<<"[ 1 ] - <potion> restores 10 hp cost 5 gold\n"
<<"[ 2 ] - <mana potion> restores 2 mana cost 5 gold \n"
<<"[ 3 ] - <power potion> restores 2 power cost 5 gold\n"
<<"choice : ";
cin>>choice;
} while ( choice < 1 || choice > 3 );
switch ( choice ) {
case 1 :
if ( gold > 0 ){
cout<<"You have buy a potion.\n"
<<"Thanks for buying.\n";
system ( "pause" );
potion++;
gold = gold - 5;
}else{
cout<<"Insufficient gold.\n";
system ( "pause" );
}
break;
case 2 :
if ( gold > 0 ){
cout<<"You have buy a mana potion.\n"
<<"Thanks for buying.\n";
system ( "pause" );
gold = gold - 5;
manaPotion++;
}else{
cout<<"Insufficient gold.\n";
system ( "pause" );
}
break;
case 3:
if ( gold > 0 ){
cout<<"You have buy a power potion.\n"
<<"Thanks for buying.\n";
system ( "pause" );
gold = gold - 5;
powerPotion++;
}else{
cout<<"Insufficient gold.\n";
system ( "pause" );
}
break;
}
menu ( );
}
void check ( int &xp , int &maxXp , int &life , int &maxLife , int &mana , int &maxMana , int &power , int &maxPower ){
if ( xp >= maxXp ){
system ( "cls" );
cout<<"CONGRATULATION YOU HAVE LVL UP .....\n";
life = life + 1;
maxLife = maxLife + 1 ;
mana = mana + 1;
maxMana = maxMana + 1;
power = power + 1;
maxPower = maxPower + 1 ;
maxXp = maxXp + 2;
}else
xp = xp + 1;
}
Any comments or suggestion to make this game better is kindly appreciated
|