Hi guys!!
I made a simple RPG where the player can move along the x and y coordinates, choose a class and meet opponents.
I accept any suggestions on how to improve game.
borba.cpp
Hi guys!!
I made a simple RPG where the player can move along the x and y coordinates, choose a class and meet opponents.
I accept any suggestions on how to improve game.
borba.cpp
#include <cstdlib>
#include <cctype>
#include <conio.h>
#include <stdio.h>
#include <iostream>
using namespace std;
//STRUCT++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
struct room
{
char description[500];
char name[32];
int sizex;
int sizey;
};
struct map
{
char name[32];
char maplook[500];
};
struct monsters
{
char name[32];
char description[500];
int lvl,str,dex,con;
int mpositionx;
int mpositiony;
};
struct player
{
char name[32];
char clas[500];
int lvl;
};
struct clas
{
char name[32];
int str,dex,con;
};
void initializeRoom();
void initializeMap();
void initializeMonsters();
void initializePlayer();
void initializeClas();
room roomArray[1];
map mapArray[1];
monsters monstersArray[2];
player playerArray[0];
clas clasArray[4];
//MAIN PROGRAM+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int main()
{
initializeRoom();
initializeMonsters();
initializePlayer();
initializeClas();
char move;
int currentposition = 0;
int npc=0;
int i;
int positionx = 5;
int positiony = 5;
char playername[32];
int playerclas=0;
int att;
int def;
int hp;
int monatt;
int mondef;
int monhp;
int enemygoblina=1,enemygoblinb=1,enemygoblinc=3,enemygoblind=4,enemygobline=5,enemygoblinf=6;
int enemyorca=1,enemyorcb=1;
int enemydragon=1;
int enemy=0;
// Creating character----------------------------------------------------------
cout << "\n\n What's your name: ";
cin >> playername;
clas: system("CLS");
cout <<" \n\n select class:";
cout <<" \n\n 1 --- Fighter";
cout <<" \n 2 --- Barbarian";
cout <<" \n 3 --- Assassin";
cout <<" \n 4 --- Ranger";
cout << "\n\n\n INPUT---> ";
cin >> i;
switch (i)
{
case 1:
//Fighter
Fighter: system("CLS"); cout <<" \n\n\n\n -Fighter- ";
cout <<"\n\n Strength 10\n Dexterity 6\n Constitution 8\n\n Do you want to be a fighter?";
cout<<"\n\n 1 --- YES";
cout<<"\n 2 --- NO\n\n\n INPUT---> ";
cin >> i;
switch (i)
{
case 1: playerclas=1;
att = (clasArray[playerclas].str/2) + (clasArray[playerclas].dex /3);
def = (clasArray[playerclas].con/2) + (clasArray[playerclas].dex /3);
hp = (clasArray[playerclas].con*4) + (clasArray[playerclas].dex *2) + (clasArray[playerclas].str);
goto moving;
break;
case 2: goto clas;
break;
default: goto Fighter;
}
case 2:
//Barbarian
Barbarian: system("CLS"); cout <<" \n\n\n\n -Barbarian- ";
cout <<"\n\n Strength 12\n Dexterity 2\n Constitution 10\n\n Do you want to be a Barbarian?";
cout<<"\n\n 1 --- YES";
cout<<"\n 2 --- NO\n\n\n INPUT---> ";
cin >> i;
switch (i)
{
case 1: playerclas=2;
att = (clasArray[playerclas].str/2) + (clasArray[playerclas].dex /3);
def = (clasArray[playerclas].con/2) + (clasArray[playerclas].dex /3);
hp = (clasArray[playerclas].con*4) + (clasArray[playerclas].dex *2) + (clasArray[playerclas].str);
goto moving;
break;
case 2: goto clas;
break;
default: goto Barbarian;
}
case 3:
//Assassin
Assassin: system("CLS"); cout <<" \n\n\n\n -Assassin- ";
cout <<"\n\n Strength 4\n Dexterity 15\n Constitution 5\n\n Do you want to be a Assassin?";
cout<<"\n\n 1 --- YES";
cout<<"\n 2 --- NO\n\n\n INPUT---> ";
cin >> i;
switch (i)
{
case 1: playerclas=3;
att = (clasArray[playerclas].str/2) + (clasArray[playerclas].dex /3);
def = (clasArray[playerclas].con/2) + (clasArray[playerclas].dex /3);
hp = (clasArray[playerclas].con*4) + (clasArray[playerclas].dex *2) + (clasArray[playerclas].str);
goto moving;
break;
case 2: goto clas;
break;
default: goto Assassin ;
}
case 4:
//Ranger
Ranger: system("CLS"); cout <<" \n\n\n\n -Ranger- ";
cout <<"\n\n Strength 6\n Dexterity 12\n Constitution 6\n\n Do you want to be a Ranger?";
cout<<"\n\n 1 --- YES";
cout<<"\n 2 --- NO\n\n\n INPUT---> ";
cin >> i;
switch (i)
{
case 1: playerclas=4;
att = (clasArray[playerclas].str/2) + (clasArray[playerclas].dex /3);
def = (clasArray[playerclas].con/2) + (clasArray[playerclas].dex /3);
hp = (clasArray[playerclas].con*4) + (clasArray[playerclas].dex *2) + (clasArray[playerclas].str);
goto moving;
break;
case 2: goto clas;
break;
default: goto Ranger;
}
default: goto clas;
}
// moving-----------------------------------
moving:system("CLS");
cout << "\n You are in "<< roomArray[currentposition].name;
cout << "\n "<< roomArray[currentposition].description;
cout << "\n\n Surface size = " << roomArray[currentposition].sizex << "," << roomArray[currentposition].sizey;
cout << "\n Your position = " << positionx << "," << positiony;
cout << "\n\n\n ---------------MOVE---------------";
cout << "\n (N)orth (S)outh (E)ast (W)est ";
cout << "\n\n\n -------------OPTIONS---------------";
cout << "\n (Q)uests (I)nventory (C)haracter (M)ap ";
cout << "\n\n\n INPUT---> ";
cin >> move;
move = toupper(move);
switch(move)
{
case 'N':
positionx = positionx +1;
break;
case 'E':
positiony = positiony +1;
break;
case 'S':
positionx = positionx -1;
break;
case 'W':
positiony = positiony -1;
break;
case 'Q':
break;
case 'C':
goto character;
break;
case 'M':
goto map;
break;
}
//enemy on the map----------------------------------------------
//goblins
if (positionx ==2 && positiony ==2 && enemygoblina == 1)
{
enemygoblina = 2;
enemy=2;
goto combat;
}
if (positionx ==6 && positiony ==3 && enemygoblinb == 1)
{
enemygoblinb = 2;
enemy=2;
goto combat;
}
if (positionx ==3 && positiony ==4 && enemygoblinc == 1)
{
enemygoblinc = 2;
enemy=2;
goto combat;
}
if (positionx ==9 && positiony ==7 && enemygoblind == 1)
{
enemygoblind = 2;
enemy=2;
goto combat;
}
if (positionx ==2 && positiony ==2 && enemygoblina == 1)
{
enemygoblina = 2;
enemy=2;
goto combat;
}
if (positionx ==6 && positiony ==3 && enemygobline == 1)
{
enemygobline = 2;
enemy=2;
goto combat;
}
//orcs
if (positionx ==0 && positiony ==8 && enemyorca == 1)
{
enemyorca= 2;
enemy=1;
goto combat;
}
if (positionx ==5 && positiony ==6 && enemyorcb == 1)
{
enemyorcb = 2;
enemy=1;
goto combat;
}
//drgon
if (positionx ==10 && positiony ==6 && enemydragon == 1)
{
enemydragon = 2;
enemy=3;
goto combat;
}
//------------------------------------------------------------------------------
if ( positionx < 0 )
{
positionx = positionx+1;
goto moving;
}
else if ( positiony < 0 )
{
positiony=positiony+1;
goto moving;
}
else if (positionx > roomArray[0].sizex)
{
positionx = positionx -1;
goto moving;
}
else if (positiony > roomArray[0].sizey)
{
positiony = positiony -1;
goto moving;
}
else
{
goto moving;
}
//map-----------------------------------------------------------------
map:system("CLS");
initializeMap();
cout << "\n\n --MAP--";
cout << "\n " << mapArray[currentposition].name;
cout << "\n\n" << mapArray[currentposition].maplook;
cout << "\n W = WALLS\n E = Enemy\n X = ground\n P = Player";
getch();
goto moving;
//character-----------------------------------------------------------------
character:system("CLS");
cout << "\n\n --CHARACTER--";
cout << "\n\nNAME: " << playername;
cout << "\nCLASS: "<< clasArray[playerclas].name;
cout << "\nLVL. " << playerArray[0].lvl;
cout << "\n\nHealth Point = " << hp;
cout << "\n\nStrenght = " << clasArray[playerclas].str;
cout << "\nDexterity = " << clasArray[playerclas].dex;
cout << "\nConstitution = " << clasArray[playerclas].con;
cout << "\n\nAttack power = " << att;
cout << "\nDefence power = " << def;
getch();
goto moving;
//combat-----------------------------------------------------------------
combat:
srand((unsigned)time(0));
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.