I'm refreshing my mind of my C++ skills,
and my older brother had the idea of creating a medieval text-based game!
He's making all the ideas and all that,
and I'm the code monkey programming it.
Here's the code:
main.cpp:
#include <iostream>
#include <string>
#include "CLASHinfo.h"
using namespace std;
int main()
{
bool running = true;
do {
CLASH();
cout << "\nRPG\n\n";
cout << "Programmed by Xarver : Designed by Fishbowl444\n\n";
cout << "[Press 1, Then Enter, to Start a New Adventure]\n"
<< "[Press 2, Then Enter, to Load an Adventure]\n"
<< "[Press z, Then Enter, to Quit]\n\n";
char entry;
cin >> entry;
if(entry == 1)
{
}
cin.get();
running = false;
}while(running == true);
return 0;
}
CLASHinfo.h:
#include <iostream>
#include <string>
using namespace std;
void YesorNofunc()
{
cout << "Are you sure?\n\n"
<< "[1] Yes\n"
<< "[2] No\n\n";
char YesorNo;
cin >> YesorNo;
if(YesorNo == 1)
{
}else if(YesorNo == 2)
{
}else {
cout << "Invalid; Try Again.";
}
}
void CLASH()
{
cout
<< " :::::::: ::: ::: :::::::: ::: ::: \n"
<< ":+: :+: :+: :+: :+: :+: :+: :+: :+: \n"
<< "+:+ +:+ +:+ +:+ +:+ +:+ +:+ \n"
<< "+#+ +#+ +#++:++#++: +#++:++#++ +#++:++#++ \n"
<< "+#+ +#+ +#+ +#+ +#+ +#+ +#+ \n"
<< "#+# #+# #+# #+# #+# #+# #+# #+# #+# \n"
<< " ######## ########## ### ### ######## ### ### \n";
}
The purpose of the YesorNofunc is it provides two parameters.
For example, if the user enters 1, it will do the first action.
If the user enters 2, it will do the second one.
For example, YesorNofunc(firstaction(), sencondaction());
The firstaction would be a function that does an action, for example:
void firstaction
{
cout << "Pie.";
}
if the user entered 1, it would print "Pie."
I'm not sure how to do this...
I want it when the user enters 1,
it continues and goes onto the new character screen.
If the user enters 2, it would go back to the main menu...
But I want this function re-usable, meaning
if you are at a shop and you are going to buy something,
before you buy it it asks, "Are you sure?"
And I can re-use it for any other thing.
I'm confused;
Can this be done in OOP?
I have been studying OOP a little...
I would like this to work, or
just any alternative for the goto in my situation.
Any help appreciated!
~ Xarver