Hey ive tried to learn C++ by myself at home and decided that the best way to motivate myself was creating ye old dos text game.
Im stuck at this so far and was wondering how can i improve my basic layout?
also since its a text game how could i add various characters and rooms?
how would i use an array for a maze? or struct for hero/monsters?
and how can i create a xp/hp that increases/decreases and saves? i/o?

Any one that helps is an instant dovahkiin :D
but any direction is appreciated

/*
  Name: Gaze of the abyss 
  Copyright: copyright my ass
  Author: xxx 
  Date: 28/11/11 03:43
  Description: Run and read the About option
*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream> //necessary for file i/o
using namespace std;



void playgame()
{

    cout << "North (N) or West (W) choose a direction."<<endl<<endl; 
    char direction;
    cin>>direction;
    switch(direction)
        {
        case 'n':
        case 'N':    
        cout << "You head North"<<endl<<endl;                                 
        break;
        case 'w':
        case 'W':     
        cout << "You head West"<<endl<<endl;
        break;
        default:
        cout<<"Invalid Character entered"<<endl<<endl;
        cout<<"Press Space to continue";                 
        break;
        }           
}

void Manual()
{
    cout<<"\n===============================================";
    cout<<"\n|---------------------------------------------|";                    
    cout<<"\n|--------------------MANUAL-------------------|";
    cout<<"\n|---------------------------------------------|";    
    cout<<"\n===============================================";
    cout<<"\n";
    cout<<"\n";
    cout<<"\n";
    cout<<"                    CONTENTS\n";
    cout<<"\n";
    cout<<"\n";
    cout<<"CONTROLS\n";
    cout<<"\n";
    cout<<"Directions;\n";
    cout<<"\n";    
    cout<<"N/n = North\n";    
    cout<<"E/e = East\n";
    cout<<"S/s = South\n";
    cout<<"W/w = West\n";
    cout<<"\n";    
    cout<<"\n";
    cout<<"\n";
    cout<<"\n";   
    cout<<"\n";      
    cout<<"Press Space to continue\n";
}

void About()
{
    cout <<"\n";
    cout <<"\n";
    cout <<"\n";
    cout <<"            Gaze of the Abyss\n";
    cout <<"\n";
    cout <<" 'When you stare into the abyss the abyss stares back at you.'\n";
    cout <<"       Friedrich Nietzsche\n";
    cout <<"\n";
    cout <<"     A Compeling story into the venture of a lone soul\n" ;
    cout <<"     trapped in an subterranean abyss\n";
    cout <<"\n";
    cout <<"\n";
    cout << " Gaze of the Abyss is an C++ project created and designed under.\n"; 
    cout <<"\n";
    cout <<"         Bloodshed Software Dev-C++ 4.9.9.2\n";
    cout <<"\n";
    cout << "         GNU GENERAL PUBLIC LICENSE\n";
    cout << "         Version 2, June 1991\n";
    cout <<"\n";
    cout << " Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n";
    cout << " 675 Mass Ave, Cambridge, MA 02139, USA\n";
    cout <<"\n";
    cout <<"\n";
    cout<<"Press Space to continue\n";
}


void menu(){
    char choice=-1;
    while (choice !='4')
    {
    cout<<"\n";
    cout<<"\n";
    cout<<"     Gaze of the Abyss\n";
    cout<<"\n";    
    cout<<" By: xxx     v 1.0\n";
    cout<<"\n";
    cout<<"\n";
    cout<<"\n=====================";                
    cout<<"\n     Main Menu      |";
    cout<<"\n=====================";
    cout<<"\n 1 - Start New Game |";
    cout<<"\n 2 - Manual         |";
    cout<<"\n 3 - About          |";
    cout<<"\n 4 - Quit           |";
    cout<<"\n=====================";
    cout<<"\n";
    cout<<"\n";          
    cout<<"\n Enter choice: ";
    cin>>choice;
        switch(choice)
        {
        case '1':
        system("CLS");             
        playgame();
        break;
        case '2':
        system("CLS");
        Manual();
        break;
        case '3':
        system("CLS");             
        About();
        break;
        case '4':
        cout<<"Thank you for playing!\n"<<endl;
        break;
        default:
        cout<<"Invalid Character entered\n";
        cout<<"\n";
        cout<<"Press Space to continue\n";               
        }
    system("pause");
    system("CLS");
    }
    }
    
int main()
{
cout<<"welcome";
menu();
return 0;
}

First things first...
Get rid of *ALL* system() calls. Clearing the screen is not necessary. Calling the operating system command PAUSE is bad. If you want to pause the game, just do a cin . It's part of the language.


Second (you may as well learn this now rather than pull your hair out later)...
Each and every time you read a single character, notice you hit the ENTER key? That is also a character, so you end up leaving junk in the input buffer for the next read -- which is rarely a good thing. Search for ways to keep the input buffer clean of junk after each input.

Third is your design.
If you don't design your program before you start coding, your code will be terrible, your program will have holes in it, it will be difficult to get parts working smoothly together. And in the end you will end up with this instead of this

In your case
- what does the game look like?
- what does it do?
- how are the 'rooms' designed?
- how are they linked together?
- how do you handle input?
- what are the commands?
- how do you translate input into commands?
and so much more...

If you want to see how the original text game works, complete with source code, see this page. Code is in many languages, so look for the C/C++ versions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.