View Full Version: First Creation, Text RPG!

C++ Learning Community > C++ Creations > First Creation, Text RPG!


Title: First Creation, Text RPG!
Description: This is my first C++ creation....


jsaniuk - July 16, 2005 05:12 AM (GMT)
Hi guys, this is my first post on this forum. I started C++ programming and after a few hours I finished my first RPG text game, it's pretty simple but took me forever becuase I did it by myself and I've tryed it out a lot and it works good now, a lot of frustration to make it, it's also pretty short. Anyway give it a try and give me some feedback please. I used Dev-C++... Any ideas you have to add to it would be great thanks.


CODE


// Text Based RPG

#include <ctime>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include<iomanip>
#include<fstream>

using std::cout;
using std::cin;
using std::endl;
using std::string;

using namespace std;
int main()
{
const int GOLD_PIECES = 3500;
string leader;
int adventurers, killed, survivors;
string Continue;

cout << "Welcome to your journey...\n\n";

cout << "The world stands at the brink of war,\n";
cout << "which path will you choose brave adventurer?\n";

cout << "Path Choices:\n\n";
cout << "1) Warrior - Strength & Agility\n";
cout << "2) Warlock - Intellect & Stamina\n";
cout << "3) Mage    - Wisdom & Dexterity\n\n";

int choice;
cout << "Choice: ";
cin >> choice;

switch (choice)
{
case 1:
cout <<"You have chosen the path of brutal force. Good luck!\n";
break;
case 2:
cout <<"You have chosen the path of destruction and demonology. Good luck!\n";
break;
case 3:
cout <<"You have chosen the path of healing and recovery spells. Good luck!\n";
break;

}

cout << "Enter a number: \n";
cin >> adventurers;

cout << "Enter a number, smaller than the first: \n";
cin >> killed;

survivors = adventurers - killed;

cout << "Please enter your name: \n";
cin >> leader;

cout << "\nA young but determined group of " << adventurers << " set out on a quest for the greater good \n";
cout << "in search of the treasure left behind from the forgotten civilizations. \n";
cout << "The group was led by " << leader << " whose chosen skills and traits would be of aide.\n";

cout << "Along the way, orcs from the burning crusade ambushed the group hoping\n";
cout << "to capture " << leader << ".\n";
cout << "The group fought their hardest led by " << leader;
cout << ", and the orcs were defeated,\n";
cout << "but at a price. \n";

cout << "Of the adventurers, " << killed << " had disappeared forever, ";
cout << "leaving just " << survivors << " in the group.\n\n";

cout << "\nThe leader " << leader << " was about to give up and let the group go their seperate\n";
cout << "paths.\n";
cout << "But as the group finished laying the dead to rest, ";
cout << "they stumbled upon\n";
cout << "the buried fortune.\n";
cout << "So the adventurers split " << GOLD_PIECES << " gold pieces.";
cout <<    leader << " kept\n";
cout << "the extra " << (GOLD_PIECES % survivors);
cout << " pieces because after all, their journey could not have\n";
cout << "been accomplished\n";
cout << "without his power and knowledge against the beast men.\n\n";
cout << "Until next time, the journey has ended...\n";



cin.ignore();
system("Pause");
std::cout<<"\n"<<std::endl;
return 0;



C-Man - July 16, 2005 05:51 AM (GMT)
:codeblks:

jsaniuk - July 16, 2005 06:22 AM (GMT)
Sorry, fixed it hehe first post and started yesterday.

tubapro12 - July 18, 2005 03:43 AM (GMT)
i think i got ripped off on the gold :lol:

okay, at the end, if you use cin.get() instead of system("pause"), you only needed to include 2 headers, string and iostream. also, you've already declared using namespace std so at end there you won't the std:: in front of cout or endl. also, the using std::... isn't needed, as long as you use using namespace std.

Rmstn1580 - December 9, 2005 01:22 AM (GMT)
You forgot the ending bracket.




* Hosted for free by InvisionFree