You are on page 1of 21

Adamson University

College of Engineering
Computer Engineering Department

RPG Game

In Partial Fulfillment
of the Requirement of the Subject
Computer Fundamentals and Programming

Presented by:

Fernandez, Iris Mae


Cichon, John Micahel J.
Lapau-os, Doli Ysabelle V.
Tabago, Quad Giandrew D.

Schedule:
TTH / 10:30-1:30 / CL2

Presented to:

Engr. Jordan Vhane D. Sardalla


Faculty Member

Date Submitted
09-05-2019
I. Description of the Project

The project is called RPG game. It is a role playing game. Is a genre of video game where
the gamer controls a fictional character (or characteristics) that undertakes a quest in an
imaginary world. Defining RPGs is very challenging due to the range of hybrid genres that have
RPG elements.

II. Source Code

#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <conio.h>
#include <windows.h>
#include <stdio.h>

using namespace std;

bool stopgame = false;


bool Endgame = false;
int Gamepseed=50;
int Level = 1;
int race;
char field[20][20];
char sine;
char name[16];
int menu();
int maingm();
int gm;
int questing();
int goblinBattle();
int showEnemyHp(int enemyhp, int attack);
int showHp(int hp, int enemyattack);
int kills=0, saves=0 , gold=0,hp=0,towns=0,escapes=0,q=1,S=0,att=0,def=0,B=0,TRUTH=0;
void town();
void Jordan();
void credits();
void IIII();
void tangent();
void menu2();
void intro();
void meme();
void move();
void rawr();
void items();
void act();
int maxhp=0;
void Shrine();
void sveme();
void BOSS();
void instruct();
void shop();
void chatter();

Computer Fundamentals and Programming Page 2


char map[20][32] =
{
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"X@ x |* x |*T*| S X",
"X----- |* |* *| x X",
"X *S*| |* |* *| X",
"X * *| |* |_ _| T X",
"X * * |_ X",
"X T| X",
"X x X",
"X S X",
"X S x X",
"X x X",
"X x X",
"X x X",
"X T x X",
"X S -------+X",
"X T B G #X",
"X -------+X",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
};
char title[30][60]=
{
"___________________________________________",
"| _______________________________________ |",
"|| __________ ||",
"|| |___ ___| ____ _ _ ________ ||",
"|| | | | _ | | |___| | | __ | ||",
"|| | | | |_|| | | _ | | | | | | ||",
"|| |__| |____| |__| |__| |_| |_| ||",
"|| ||",
"|| ______ _____ ||",
"|| | __ | | ___| ||",
"|| | | | | | |__ ||",
"|| | |__| | | __| ||",
"|| |______| |__| ||",
"|| _______ ___ ______ ______ ||",
"|| | ____| | | | ____| | __ | ||",
"|| | |__ | | | |__ | | | | ||",
"|| | __| | | | __| | | | | ||",
"|| | |____ | |____ | | | |__| | ||",
"|| |______| |______||_| |______| ||",
"||_______________________________________||",
"|_________________________________________|"};
int main ()
{
system("cls");
menu();

return 0;
}

void intro()
{

Computer Fundamentals and Programming Page 3


system("cls");

cout<<"You wake up in an unknown place\n";


system("pause");
cout<<"You cannot remember who you are\n";
system("pause");
cout<<"But a voice within you says\n";
system("pause");
cout<<"Hero the world is plunging into #$@#SDSASD darkness we NEED you!
to fight the enemies\n";
system("pause");
cout<<"As you look around your mind mumbles\n";
system("pause");
cout<<"What race would you want to be?\n";
system("pause");
system("cls");
cout<<"Choose a number\n";
system("pause");
cout<<"\n1.)Human(hp=10, attack=5, defence=8)\n2.)Elfo(Hp=5, attack=9,
defence=4(has magic)))\n";
cin>>race;
choose:
if (race==1)
{ Beep(500,500);
maxhp+=20,def+=10, att+=5,hp+=maxhp;
cout<<"Your hp is="<<maxhp<<"\nYour Defense
is="<<def<<"\nYour Attack is="<<att<<endl;

}
else if(race==2)
{ Beep(500,500);
cout<<"He is a half elf he doesn't have magic #BamBoozled'";
maxhp+=5,def+=4,att+=9,hp+=maxhp;
cout<<"Your hp is="<<maxhp<<"\nYour Defense
is="<<def<<"\nYour Attack is="<<att<<endl;

}
else
{
cout<<"Invalid race please input again";
goto choose;
}

instruct();
getch();
}
int menu()

{
int x=0, y=0;
system("cls");
for (int y=0; y<30; y++)
{
cout << title[y]<< endl;
}

Computer Fundamentals and Programming Page 4


system("pause");
system("color C0");
int answer;
choose:
system("cls");

cout<<"1.)Play game\n2.)Credits\n3.)Our proffessor\nIIII.)••¤•W?!*B¦5ø+y\n


Choose a Number!!";

cin>>answer;

if(answer==1)
{
system("cls");
Beep(500,500);
intro();

}
else if(answer==2)
{ Beep(500,500);
credits();
}
else if(answer==3)
{ Beep(500,500);
Jordan();
}
else if(answer==4)
{ Beep(500,500);
IIII();
}
else
Beep(600,500);
Beep(500,500);
cout<<"choose again\n\n\n";
goto choose;
answer=0;
cout<<answer;
return 0;

void menu2()
{
system("cls");
int answer;
choose:

cout<<"Welcome to the TOWN OF ELFO!!\n";


cout<<"1.)Play game\n2.)Credits\n3.)Our proffessor\n4.) Personal Messages\n";

cin>>answer;

if(answer==1)
{ Beep(500,500);
system("cls");
intro();

Computer Fundamentals and Programming Page 5


}
else if(answer==2)
{ Beep(500,500);
credits();
}
else if(answer==3)
{ Beep(500,500);
Jordan();
}
else if(answer==4)
{ Beep(500,500);
meme();
}

else
Beep(600,500);
Beep(500,500);
cout<<"choose again\n";
goto choose;

void Jordan()
{
system("cls");
cout<<"Labyu ";
system("pause");
menu2();
}
void credits()
{ system("cls");
cout<<"Members:\nJohn Cichon\nIris Fernandez\nDoli Lapu-os\nQuayd
Tabago\n #4 is reality\n";
system("pause");
menu2();
}
void tangent()
{
switch(sine)

case 'a':
{ Beep(500,0);
cout<<"help me";

case 'b':
cout<<"kill me";

case 'c':
{
cout<<"stay away";
break;
}
}

Computer Fundamentals and Programming Page 6


}
void IIII()
{
int Why=1;
while (Why=1)
{
cout<<"help";

if(kbhit())
{
menu2();

}
}

void meme()
{
cout<<"hi";
system("pause");
menu2();
}

void move()
{

int x=0, y=0;

system("cls");

for (int y=0; y<27; y++)


{
cout << map[y]<< endl;
}
for (int y = 0; y<27; y++)
{
for (int x = 0; x<32; x++)
{

switch(map[y][x])
{
case'@':
{
if(GetAsyncKeyState(VK_UP) !=0)
{
int y2 = (y-1);
switch(map[y2][x])
{
case' ':
{
map[y][x]=' ';

Computer Fundamentals and Programming Page 7


y-=1;

map[y2][x]='@';
}
break;
case 'x':
{
map[y][x]=' ';
y-=1;

map[y2][x]='@';
rawr();
}

break;
case 'T':
{
map[y][x]='T';
y-=1;

map[y2][x]='@';
town();

}
break;
case 'G':
{
map[y][x]='G';
y-=1;

map[y2][x]='@';
menu();

}
break;
case 'S':
{
map[y][x]=' ';
y-=1;

map[y2][x]='@';
Shrine();
}
case 'B':
{
map[y][x]=' ';
y-=1;

map[y2][x]='@';
BOSS();
}
case '#':
{
map[y][x]=' ';
y-=1;

Computer Fundamentals and Programming Page 8


map[y2][x]='@';
sveme();
}
}
}
else if(GetAsyncKeyState(VK_DOWN)
!=0)
{
int y2 = (y+1);
switch(map[y2][x])
{
case' ':
{
map[y][x]=' ';
y+=1;

map[y2][x]='@';
}
break;
case 'x':
{
map[y][x]=' ';
y+=1;

map[y2][x]='@';
rawr();
}
break;
case 'T':
{
map[y][x]=' ';
y+=1;

map[y2][x]='@';
towns+=1;
town();

}
break;
case 'S':
{
map[y][x]=' ';
y+=1;

map[y2][x]='@';
Shrine();
}
case 'B':
{
map[y][x]=' ';
y+=1;

map[y2][x]='@';
BOSS();
}

Computer Fundamentals and Programming Page 9


case '#':
{
map[y][x]=' ';
y+=1;

map[y2][x]='@';
sveme();
}
}
}
else if(GetAsyncKeyState(VK_RIGHT)
!=0)
{
int x2 = (x+1);
switch(map[y][x2])
{
case' ':
{
map[y][x]=' ';
x+=1;

map[y][x2]='@';
}
break;
case 'x':
{
map[y][x]=' ';
x+=1;

map[y][x2]='@';
rawr();}break;
case 'T':
{
map[y][x]='T';

map[y][x2]='@';
x2+=1;
towns+=1;
town();
}
break;
case 'S':
{
map[y][x]=' ';
x+=1;

map[y][x2]='@';
Shrine();
}
case 'B':
{
map[y][x]=' ';
x+=1;

map[y][x2]='@';
BOSS();

Computer Fundamentals and Programming Page 10


}
case '#':
{
map[y][x]=' ';
x+=1;

map[y][x2]='@';
sveme();
}
}
}
else if(GetAsyncKeyState(VK_LEFT) !=0)
{
int x2 = (x-1);
switch(map[y][x2])
{
case' ':
{
map[y][x]=' ';
x-=1;

map[y][x2]='@';
}
break;
case 'x':
{
map[y][x]=' ';
x-=1;

map[y][x2]='@';
rawr();
}
break;
case 'T':
{
map[y][x]='T';

map[y][x2]='@';
x2-=1;
towns+=1;
town();
}
break;
case 'S':
{
map[y][x]=' ';
x-=1;

map[y][x2]='@';
Shrine();
}
case 'B':
{
map[y][x]=' ';
x-=1;

Computer Fundamentals and Programming Page 11


map[y][x2]='@';
BOSS();
}
case '#':
{
map[y][x]=' ';
x-=1;

map[y][x2]='@';
sveme();
}
}
}

}
}
}
}Sleep(Gamepseed);
}

void rawr()
{
system("cls");

cout<<"enemy Attack";
Sleep(500);
int enmhp=(1+rand()%10)*(Level*5), enmatt=(att+(kills*Level));
int hitGoblin;
maxhp==(Level*20);
att=(att+att*Level)+(S*20),def=(def+(def*Level));

again:
srand(time(0));
if (enmhp>0)
{

shoot:
system("cls");
cout<<"Your hp:"<<hp<<"enemy hp"<<enmhp;
cout << "\nAction \n1.)Attack 3.)Defend\n2.)Item
4.)Act\n";
cin >> hitGoblin;
if(hitGoblin==1)
{
enmhp-=(att*(1+rand()%(10*Level)));
cout << "\nYou hit the goblin.\n"<<att;
cout << "The goblin now has " << enmhp << "HP
left.\n\n";
cout << "The goblin hit you back.\n";
cout << "You now have " << hp << "HP left.\n\n";
system("pause");
if (enmhp<=0)
{

Computer Fundamentals and Programming Page 12


cout<<"you win";Sleep(500);
kills+=1;
Level+=1;
cout<<"Level up";
hp+=maxhp;
gold+=10*(1+rand()%10);
cout<<"You recieved="<<gold;
maingm();

}
hp-=(enmatt+(1+rand()%10*kills));
cout << "The goblin hit you back.\n";
cout << "You now have " << hp << "HP left.\n\n";
if(hp<=0)
{
cout<<"\nyou Died\n";
system("pause");
Endgame == true;
menu2();
}
else if(enmhp>0)
{
goto shoot;
}

}
else if(hitGoblin==3)
{
cout << "You chose not to hit and heal but the goblin hit
you instead\n";hp+=att;
cout << "You now have " << hp << "HP left.\n\n";
if (hp>maxhp)
{
hp-=(hp-maxhp);
}

goto shoot;
}
else if(hitGoblin==2)
{ chois:
int item;
system("cls");
cout<<"1.)Magical infinite
potion\n2.)MightyEnema3.)return?";
cin>>item;
if (item==1)
{
cout<<"This will replenish your
health!\nWill you use it?\n 1.)Yes\n2.)No";
int item2;
cin>>item2;
if (item2=1)
{
hp+=maxhp;
item2=0;

Computer Fundamentals and Programming Page 13


goto shoot;
}
else
{
goto chois;
}
}
else if(item==2)
{
int item3;
cout<<"This will damage
your enemy to 50% of its health\nWill you use it?\n1.) Yes\n2.) No";
cin>>item3;
if (item3=1)
{
enmhp-=(enmhp/2);
item3=0;
goto shoot;
}
}
else if(item==3)
{
goto shoot;
}
else
{
cout<<"Invalid answer";
system("pause");
goto chois;
}
}
else if(hitGoblin==4)
{
again1:
system("cls");
int act;
cout<<"\nWhats your act?\n1.)Run
2.)Spare";
cin>>act;
if (act==1)
{
cout<<"You ran away";
escapes+=1;
maingm();
}
else if(act==2)
{
cout<<"You have spared the
enemy ";
saves+=1;
maingm();

}
else
cout<<"Invalid answer";
system("pause");

Computer Fundamentals and Programming Page 14


system("cls");
goto again1;

else
{
cout << "That is not a valid choice.\n\n";
goto shoot;
}
}
}

void town()
{
again:
system("cls");
cout<<"Welcome to our humble town";Sleep(200);

int choice;
cout<<"What can i do for you today?\n 1.)Quest\n2.)Shop\n3.)Talk\n4.)Leave";
cin>>choice;

if (choice==1)
{
questing();

}
else if(choice==2)
{
shop();
}
else if(choice==3)
{
chatter();
}
else if (choice==4)
{
maingm();
}
else
{
cout<<"invalid action";
goto again;
}
}

int maingm()
{
system("pause");
while (stopgame== false)

Computer Fundamentals and Programming Page 15


{
move();
if (Endgame==true)
{
if (B!=1)
{

cout<<"You have failed please GIT


GUD NEXT TIME\n";
system("pause");
return 0;

}
else if (B==1)
{
if(TRUTH!=1)
{
cout<<"You have
saved the world though have you learned who you are?\n";
system("pause");
cout<<"\nShrines are
the key!";
system("pause");
return 0;
}
}
}
}
}

int questing()
{
if (q==1)
{
cout<<"\nYou must kill 3 demons\n";
system("pause");
if (kills>=3)
{
Level+=1;
q+=1;
cout<<"JFBUT wEhre thhei eben demons?";

sleep(1000);
system("cls");
cout<<"Level up!!!!";
maingm();
}
}
else if(q==2)
{
cout<<"You must visit 3 towns\n";

if (towns>=3)
{

Computer Fundamentals and Programming Page 16


cout<<"Baht whewre thuhy all good?\n Level
up!!!!";Level+=1;
sleep(1000);q+=1;
cout<<"Level up!!";
system("pause");
maingm();
}
}
else if(q==3)
{

}
}

void instruct()
{

cout<<"INSTRUCTIONS!!!!\nUse the arrows to move\nT==Town


x==Enemy\n@==You S==Shrine\nG==Endgame B==Boss\n Have Fun!!";
maingm();
}
void Shrine()
{
if (S==0)
{
int answer;
system("cls");
cout<<"You must show your worth! Answer thy question to be granted a
treasure";
cout<<"What is the powerhouse of the cell?";
cout<<"\n1.)Mithochondria 2.)Glucose\n3.)Rhysosomes 4.)Queef";
cin>>answer;
if (answer=1)
{
cout<<"You are correct\nThus You will recieved the card of
FATE(adds Inteligence)";
S+=1;
system("pause");
maingm();

}
else if(answer!=1)
{
cout<<"You have failed this test";
system("pause");
maingm();
}

}
system("pause");
}
void BOSS()
{
cout<<"Lol";
system("pause");
maingm();

Computer Fundamentals and Programming Page 17


}
void sveme()
{
if (S<5)
{
cout<<"Hey you! \n"<<sleep(1000)<<"do you know who you really are?";
}
else if(S==5)
{
cout<<"You regained your memory and finally see what is true\n You suffer
schizophrenia and have been living in a world of fantasy though killing those that are innocent as
you are blinddeddddddddddddd\n";
cout<<"\nNow What is your name?";
cin>>name;
}

}
void shop()
{
cout<<"lol";
maingm();
}
void chatter()
{
cout<<"lol";
maingm();
}Example:

III. Sample Output

Computer Fundamentals and Programming Page 18


Computer Fundamentals and Programming Page 19
IV. Pictures

Computer Fundamentals and Programming Page 20


Computer Fundamentals and Programming Page 21

You might also like