Here is what I have so far
Game.cpp:
CODE
#include "game.h"
#include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <string>
#include <stdio.h>
using namespace std;
bool Game::run(void)
{
char key = ' ';
char gender = ' ';
char startop = ' ';
char quit = ' ';
const char *race;
string gend;
string fname;
string lname;
string age;
beginning:
system("cls");
cout << "\n Welcome to Dark Lotus RPG!!\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout << " (S)tart\n";
cout << " (C)ontinue\n";
cout << " (Q)uit";
cout << "\n\n\n\n\n\n Dark Lotus was programmed by Daniel Hopkins.";
while (startop != 's' || startop != 'c' || startop != 'q')
{
while (!getInput(&startop))
{
}
if (startop == 's' || startop == 'S')
{
goto start;
}
else if (startop == 'c' || startop == 'C')
{
system("cls");
cout << "\n Sorry this function is not working atm, please choose 'Start' or 'Quit'.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout << " press enter...";
cin.ignore(cin.rdbuf()->in_avail() +1);
goto beginning;
}
system("cls");
cout << "\n Are you sure you want to quit?(y/n)";
while (quit != 'y' || quit != 'n')
{
while (!getInput(&quit))
{
}
if (quit == 'y')
{
goto exit;
}
else if (quit == 'n')
{
startop = ' ';
quit = ' ';
goto beginning;
}
}
}
start:
system("cls");
cout << "\n I need to acquire some information from you. Before we begin your long journey \n\n I would like to ask you a couple of questions.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout << " press enter...";
cin.ignore(cin.rdbuf()->in_avail() +1);
info:
system("cls");
cout << "\n What is your first name? ";
cin >> fname;
system("cls");
cout << "\n What is your last name? ";
cin >> lname;
system("cls");
cout << "\n How old are you? ";
cin >> age;
system("cls");
cout << "\n What is your gender?(m/f) ";
while (gender != 'm' || gender != 'f')
{
while (!getInput(&gender))
{
}
if (gender == 'm' || gender == 'M')
{
gend = "male";
goto raceselection;
}
else if (gender == 'f' || gender == 'F')
{
gend = "female";
goto raceselection;
}
}
raceselection:
system("cls");
cout << "\n Choose your race:\n\n";
cout << " Press A - Elf\n";
cout << " Press B - Human\n";
cout << " Press C - Orc\n";
cout << " Press D - Gnome\n";
cout << " Press E - Faery\n";
cout << " Press F - Halfling\n";
cout << " Press G - Half-Elf\n";
cout << " Press H - Dragonian\n";
cout << " Press I - Undead\n\n";
cout << " Or Press Q - Quit";
while (key != 'q')
{
while (!getInput(&key))
{
}
if (key == 'a')
{
char elf = ' ';
system("cls");
cout << "\n Are you sure you want to be an Elf?(y/n)";
while (elf != 'y' || elf != 'n')
{
while (!getInput(&elf))
{
}
if (elf == 'y')
{
race = "Elf";
goto cont;
}
else if (elf == 'n')
{
goto raceselection;
}
}
}
else if (key == 'b')
{
char human = ' ';
system("cls");
cout << "\n Are you sure you want to be a Human?(y/n)";
while (human != 'y' || human != 'n')
{
while (!getInput(&human))
{
}
if (human == 'y')
{
race = "Human";
goto cont;
}
else if (human == 'n')
{
goto raceselection;
}
}
}
else if (key == 'c')
{
char orc = ' ';
system("cls");
cout << "\n Are you sure you want to be an Orc?(y/n)";
while (orc != 'y' || orc != 'n')
{
while (!getInput(&orc))
{
}
if (orc == 'y')
{
race = "Orc";
goto cont;
}
else if (orc == 'n')
{
goto raceselection;
}
}
}
else if (key == 'd')
{
char gnome = ' ';
system("cls");
cout << "\n Are you sure you want to be a Gnome?(y/n)";
while (gnome != 'y' || gnome != 'n')
{
while (!getInput(&gnome))
{
}
if (gnome == 'y')
{
race = "Gnome";
goto cont;
}
else if (gnome == 'n')
{
goto raceselection;
}
}
}
else if (key == 'e')
{
char faery = ' ';
system("cls");
cout << "\n Are you sure you want to be a Faery?(y/n)";
while (faery != 'y' || faery != 'n')
{
while (!getInput(&faery))
{
}
if (faery == 'y')
{
race = "Faery";
goto cont;
}
else if (faery == 'n')
{
goto raceselection;
}
}
}
else if (key == 'f')
{
char halfling = ' ';
system("cls");
cout << "\n Are you sure you want to be a Halfling?(y/n)";
while (halfling != 'y' || halfling != 'n')
{
while (!getInput(&halfling))
{
}
if (halfling == 'y')
{
race = "Halfling";
goto cont;
}
else if (halfling == 'n')
{
goto raceselection;
}
}
}
else if (key == 'g')
{
char halfelf = ' ';
system("cls");
cout << "\n Are you sure you want to be a Half-Elf?(y/n)";
while (halfelf != 'y' || halfelf != 'n')
{
while (!getInput(&halfelf))
{
}
if (halfelf == 'y')
{
race = "Half-Elf";
goto cont;
}
else if (halfelf == 'n')
{
goto raceselection;
}
}
}
else if (key == 'h')
{
char dragonian = ' ';
system("cls");
cout << "\n Are you sure you want to be a Dragonian?(y/n)";
while (dragonian != 'y' || dragonian != 'n')
{
while (!getInput(&dragonian))
{
}
if (dragonian == 'y')
{
race = "Dragonian";
goto cont;
}
else if (dragonian == 'n')
{
goto raceselection;
}
}
}
else if (key == 'i')
{
char undead = ' ';
system("cls");
cout << "\n Are you sure you want to be a Undead?(y/n)";
while (undead != 'y' || undead != 'n')
{
while (!getInput(&undead))
{
}
if (undead == 'y')
{
race = "Undead";
goto cont;
}
else if (undead == 'n')
{
goto raceselection;
}
}
}
}
system("cls");
quit = ' ';
cout << "\n Are you sure you want to quit?(y/n)";
while (quit != 'y' || quit != 'n')
{
while (!getInput(&quit))
{
}
if (quit == 'y')
{
goto exit;
}
else if (quit == 'n')
{
quit = ' ';
key = ' ';
goto raceselection;
}
}
exit:
system("cls");
cout << "\n You have chosen to exit the game. Have a nice day!";
cin.ignore(cin.rdbuf()->in_avail() +1);
return true;
cont:
char infconf = ' ';
infconf:
system("cls");
cout << "\n This is the information I have gathered:\n\n Your name is "
<< fname << " " << lname << " you are a " << gend << " " << race <<
" and you are " << age << "\n\n years old. Is this information correct?(y/n/Q)";
while (infconf != 'y' || infconf != 'n' || infconf != 'q')
{
while (!getInput(&infconf))
{
}
if (infconf == 'y')
{
goto storystart;
}
else if (infconf == 'n')
{
goto info;
}
else if (infconf == 'q')
{
system("cls");
cout << "\n Are you sure you want to quit?(y/n)";
while (quit != 'y' || quit != 'n')
{
while (!getInput(&quit))
{
}
if (quit == 'y')
{
goto exit;
}
else if (quit == 'n')
{
quit = ' ';
infconf = ' ';
goto infconf;
}
}
}
}
storystart:
system("cls");
cout << "\n Great to meet you, my name is sgk'uhmklit'rehtlire which roughly translates to \n\n Shayla in your native tongue.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout << " press enter...";
cin.ignore(cin.rdbuf()->in_avail() +1);
system("cls");
cout << "\n This world is being devoured by the infamous Dark Lotus. You have been \n\n resurrected because you and you alone are the only one who can stop him.\n\n Please save our world from this vile Dragon.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout << " press enter...";
cin.ignore(cin.rdbuf()->in_avail() +1);
}
bool Game::getInput(char *race)
{
if (_kbhit())
{
*race = _getch();
return true;
}
return false;
}
Main.cpp:
CODE
#include "game.h"
int main()
{
Game gameControl;
gameControl.run();
return 0;
}
Game.h:
CODE
#ifndef GAME_H
#define GAME_H
class Game
{
public:
bool run(void);
protected:
bool getInput(char *race);
void timerUpdate(void);
};
#endif
Now just remember this is not a game I am going to release, I am making this solely for learning purposes so it will not be very original. And also it is in a very original stage pretty much the the beginning. And also I am very new to programming so please don't bash on me too much about how I have things set up. If you have advise I would love to hear it of course.
What I am having trouble with is how to make the age only accept numbers instead of both.
*edit* Also the reason I have all those /n/n/n/n is just for me because the windows size in Visual Studio 2008 Express, i actually don't know how else to make it so it looks like the way it is without skipping lines like that. */edit*
This post has been edited by kiasta: 7 Jun, 2008 - 05:48 AM