03-19-2011, 10:49 AM
Just some short RPG with a story line:
Code:
#include <iostream>
using namespace std;
int main() {
int input;
struct player {
int hp;
int hpmax;
int lvl;
int str;
int magicstr;
int magicamm;
int magic2str;
int magic2amm;
int gold;
int exp;
int expmax;
};
player player1;
player1.hp = 10;
player1.hpmax = 10;
player1.lvl = 1;
player1.str = 1;
player1.magicstr = 2;
player1.magicamm = 2;
player1.magic2str = 3;
player1.magic2amm = 3;
player1.exp = 0;
player1.expmax = 50;
player1.gold = 0;
player mons;
mons.hp = 7;
mons.hpmax = 7;
mons.str = 1;
player boss;
boss.hp = 20;
boss.hpmax = 20;
boss.str = 3;
main:
system("cls");
cout << " The Lords greet you\n" << endl;
cout << " [1]Town" << endl;
cout << " [2]exit" << endl;
cout << " [3]Stats" << endl;
cout << ":: ";
cin >> input;
if (input == 1) goto town;
if (input == 2) system("exit");
if (input == 3) {
cout << "Your Statistics are:\n";
cout << "[Hp]: " << player1.hp << "[HpMax]: " << player1.hpmax << endl;
cout << "[Strenght]: " << player1.str << endl;
cout << "[Experience]: " << player1.exp << "[ExperieceMax]: " << player1.expmax << endl;
cout << "[Gold]: " << player1.gold << endl;
cout << "[Level]: " << player1.lvl;
system("pause>nul");
goto main;
}
town:
system("cls");
cout << " There is a girl in danger!\n" << endl;
cout << " HELP! HELP!\n" << endl;
cout << " [1]:Help out\n" << endl;
cout << " [2]:Chicken out\n" << endl
;cout << " Note: If you chicken out, you will be sent back to the main place" << endl;
cout << ":: ";
cin >> input;
if (input == 1) goto help;
if (input == 2) goto main;
help:
if (player1.hp <= 0) {
cout << "You have been slain by the Monster!";
getchar();
player1.hp = player1.hpmax;
mons.hp = mons.hpmax;
goto town1;
}
if (mons.hp <= 0) {
cout << "You have slain the Monster!" << endl;
cout << "You earned 25 experience\n";
player1.exp += 25;
system("pause>nul");
if (player1.exp >= player1.expmax) {
player1.expmax *= 2;
cout << " [1]:Increase Hp[+3]" << endl;
cout << " [2]:Increase Strenght[+3]";
cin >> input;
if (input == 1) {
player1.hpmax += 3;
player1.hp = player1.hpmax;
player1.lvl += 1;
mons.hp = mons.hpmax;
goto town1;
}
if (input == 2) {
player1.str += 3;
player1.lvl += 1;
player1.hp = player1.hpmax;
mons.hp = mons.hpmax;
goto town1;
}
} else {
mons.hp = mons.hpmax;
player1.hp = player1.hpmax;
goto town1;
}
}
system("cls");
cout << "You are against the wolves whom has been attacking the little girl\n";
cout << "Level: " << player1.lvl << endl;
cout << "Hp: " << player1.hp << ":" << player1.hpmax << " " << "MonsterHp: " << mons.hp << ":" << mons.hpmax << endl;
cout << " [1]:Attack\n";
cout << " [2]:Magic\n";
cout << " [3]:Flee\n";
cin >> input;
switch(input) {
case 1:
mons.hp -= player1.str;
player1.hp -= mons.str;
goto help;
break;
case 3:
goto town1;
case 2:
cout << "Choose what type of Magic you wish to use: " << endl;
cout << " [1]: Bolt_" << "[" << player1.magicamm<< "]" << endl;
cout << " [2]: Fire_" << "[" << player1.magic2amm << "]" << endl;
cout << ":: ";
cin >> input;
if (input == 1) {
if (player1.magicamm != 0) {
mons.hp -= player1.magicstr;
player1.hp -= mons.str;
player1.magicamm -= 1;
goto help;
} else {
cout << "Sorry, you ran out of ammo";
system("pause>nul");
goto help;
}
}
if (input == 2) {
if (player1.magic2amm != 0) {
mons.hp -= player1.magic2str;
player1.hp -= mons.str;
player1.magic2amm -= 1;
goto help;
} else {
cout << "Sorry, you ran out of ammo";
system("pause>nul");
goto help;
}
}
}
town1:
player1.magicamm = 2;
player1.magic2amm = 3;
system("cls");
cout << "You have entered in a in-danger town\n";
cout << " [1]: Fight boss\n";
cout << " [2]: Escape\n";
cout << ":: ";
cin >> input;
if(input == 1) goto boss;
if (input == 2) goto main;
boss:
if(boss.hp <= 0) {
cout << "You slain the Boss!\n";
cout << "You earned 50 experience\n";
}
if (mons.hp <= 0) {
cout << "You have slain the Monster!" << endl;
cout << "You earned 25 experience\n";
player1.exp += 25;
system("pause>nul");
if (player1.exp >= player1.expmax) {
player1.expmax *= 2;
cout << " [1]:Increase Hp[+3]" << endl;
cout << " [2]:Increase Strenght[+3]";
cin >> input;
if (input == 1) {
player1.hpmax += 3;
player1.hp = player1.hpmax;
player1.lvl += 1;
boss.hp = boss.hpmax;
goto town1;
}
if (input == 2) {
player1.str += 3;
player1.lvl += 1;
player1.hp = player1.hpmax;
boss.hp = boss.hpmax;
goto town1;
}
} else {
boss.hp = boss.hpmax;
player1.hp = player1.hpmax;
goto town1;
}
}
if(player1.hp <= 0) {
cout << "You have been slain by the Boss!\n";
system("pause");
player1.hp = player1.hpmax;
boss.hp = boss.hpmax;
goto town1;
}
system("cls");
cout << "You are against the most powerful enemy in the first town\n";
cout << "Hp: " << player1.hp << " " << "Boss Hp: " << boss.hp << endl;
cout << " [1]: Attack\n";
cout << " [2]: Magic\n";
cout << " [3]: Flee\n";
cout << ":: ";
cin >> input;
switch(input) {
case 1:
boss.hp -= player1.str;
player1.hp -= boss.str;
goto boss;
break;
case 3:
goto town1;
case 2:
cout << "Choose what type of Magic you wish to use: " << endl;
cout << " [1]: Bolt_" << "[" << player1.magicamm<< "]" << endl;
cout << " [2]: Fire_" << "[" << player1.magic2amm << "]" << endl;
cout << ":: ";
cin >> input;
if (input == 1) {
if (player1.magicamm != 0) {
boss.hp -= player1.magicstr;
player1.hp -= boss.str;
player1.magicamm -= 1;
goto boss;
} else {
cout << "Sorry, you ran out of ammo";
system("pause>nul");
goto boss;
}
}
if (input == 2) {
if (player1.magic2amm != 0) {
boss.hp -= player1.magic2str;
player1.hp -= boss.str;
player1.magic2amm -= 1;
goto boss;
} else {
cout << "Sorry, you ran out of ammo";
system("pause>nul");
goto boss;
}
}
}
return 0;
}