Basic parts of text based RPGs?

Could someone put examples of how you'd type yes or no scenarios for a text based RPG? And I mean a really basic like 'you see blah blah what do you do?'.
Also, how would you finish a code like this.
Sorry I'm fairly new to this :p
1
2
3
4
5
6
7
8
9
10
11
12
char response;
cout << "Do you want to turn left? (y/n): "
cin >> response;

if (response == 'Y' || response == 'y')
{
  turn_left();
}
else
{
  turn_right();
}
Last edited on
Every week I see a topic on text based RPG and yet I never see a finished one get posted...
@Mats: Trust me, I may be the epitome of noob right now, however I'm very determined.
@Stewbond: is that all I need for the options yes and no?
You can have any options you want.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
#include <string> 
std::string response = "";
bool inputvalid = 0; 
do
{
    cout << "Do you want to move left, right, forward, back"; 
    cin >> response; 
    if(response == "left" || response == "right" || response == "forward" || response == "back")
    {
        inputvalid = 1; 
    }
    else
    {
        cout << "Input invalid\n"; 
    }
}while(inputvalid == 0)

if(response == "left")
    {
        //Do something
    }
    else if(response == "right")
    {
        //Do something
    }
    //... The rest of the options go here as else if 
Last edited on
You may to also design a character/race creation option, and the skills of the character will determine how good the character is at a certain decision. For example, a Attack skill of 20 will need to be required to kill a Hobgoblin or something.
-Run energy (add agility or stamina potions and stuff)
-A shop for the player to buy/sell items(swords,shields,armors,ingredients and whatnot...)
-Magic Attacks (water spells, earth spells, fire spells and so on...)
-Range Attacks(Rapid fire, accurate attacks, switch to crossbow etc...)

basically you can achieve all these with classes/if-else statements/enumerators/arrays or vectors.
pretty basic.
Last edited on
Things get pretty non-basic if you start doing stuff like dungeon generation, stat balancing, managing large amounts of files code etc... This is a really huge task.
I'm seriously thinking of making an extremely short and basic one; no dungeon generation, no stat balancing, nothing. Just 'you see blah blah do you blah or blah'. I want to at least grab the basics.
Here's some ideas:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cout<<"As you were walking down the road you've encountered a goblin\n";
cout<<"The goblin wants to take your items!\n";
cout<<"What will you do?\n";
cout<<"1 - Give the goblin all my items\n";
cout<<"2 - Threaten the goblin and tell him to back off at once!\n";
cin>>choice;
if ( choice == 1 )
{
cout<<"You gave all your items to the goblin.\n";
inventory.empty();
} 
else if ( choice == 2 )
{
//.......
}



And you could add little things like that:

1
2
3
4
5
6
7
8
9
10
11
12
cout<<"Would you like to search the barrel? (y/n)\n";
cin>>choice;
if ( choice == 'y' )
{
cout<<"You decided to search the barrel...\n";
cout<<"You've found a healing potion!\n";
inventory.push_back("Health Potion");
}
else
{
cout<<"You decided to leave the barrel be.\n";
}


and as i mentioned previously, Make a shop where the player can sell or buy equipments and whatnot...
Last edited on
Topic archived. No new replies allowed.