ok here is my project here so far:

Main.cpp

#include "Library.h"

void main()
{
    //GENERIC WECLOME SCREEN
    cout <<"\n\nWelcome to Hollow's Eye\n";
    cout << "<Programmed by Ethan Rigel>\n";

    cout << "Hollow's Eye a once bountiful and gorgeous land but alas; the\n";
    cout << "Mighty Dragon has destroyed and ravaged our once beautiful landscape.\n";
    cout << "You must rise against this evil warlord and destroy him to save our land;\n";
    cout << "be careful though, for his minions roam the land searching for prey.\n\n";

    Wait();

    Crossroads();

    cout << "\n\nThank you for playing Hollow's Eye. Please play again soon\n\n";
}

Town.cpp

#include "Library.h"

//TOWN

bool Town()
{

    int choice = 0;

    while (choice != 5)
    {
        cout << "You walk into town.\n";
        cout << "Everywhere you look you see people going  about their daily lives.\n";
        cout << "To your left you spot an INN and to your right an ARMORY and ITEM SHOP.\n\n";

        Wait();

        cout << endl;

        cout << "What would you like to do\n"
        cout << "1: Enter INN\n";
        cout << "2: Enter ARMORY\n";
        cout << "3: Enter ITEM SHOP\n";
        cout << "4: Check Stats\n";
        cout << "5: Leave Town\n";

        cout << ">";

        cin >> choice;

        cout << endl;

        switch (choice)
        {
            case 1;
                {
                    //INN();
                    break;
                }
            case 2;
                {
                    //ARMORY();
                    break;
                }
            case 3;
                {
                    //ITEM SHOP();
                    break;
                }
            case 4;
                {
                    //STATS();
                    break;
                }
        default: break;
        }

    }

    return true;
}

Library.h

#include <iostream>
using namespace std;

#include "Global.h"

Battle.cpp

//BATTLE

#include "Library.h"

bool Battle()
{
    return false;
}

Crossrodas.cpp

#include "Library.h" 

//CROSSROADS 

// GLOBAL VARIABLES 

bool glcomplete = false; 
bool fcomplete = false; 
bool scomplete = false; 
bool gcomplete = false; 
bool ccomplete = false; 

PLAYER player; 


bool Crossroads() 
{ 
//set player default values 
     cout << "What is your name hero?\n\n"; 
     char name[32]; 
     cout << ">"; 
     cin.getline(name,32,'\n'); 
     player.SetName(name); 

     cout << "\n"; 

     int choice = 0; 

     while (choice != 10) 
     { 
           cout << "You stand at the center of several roads going off in many directions.\n"; 
           cout << "There is a small town behind you full of shops and people.\n\n"; 

           cout << "Which path do you choose?\n\n"; 
           cout << "1: Town\n"; 
           cout << "2: Summoning Portal\n"; 

           if (!glcomplete) 
                 cout << "3: Grasslands Road (QUEST)\n"; 

           if (glcomplete && !fcomplete) 
                 cout << "4: Forest Road (QUEST)\n"; 

           if (fcomplete && !scomplete) 
                 cout << "5: Swamp Road (QUEST)\n"; 

           if (scomplete && !gcomplete) 
                 cout << "6: Graveyard Road (QUEST)\n"; 

           if (gcomplete && !ccomplete) 
                 cout << "7: Castle Road (QUEST)\n"; 

           cout << "9: View Players Stats\n"; 
           cout << "10: Exit Game\n"; 

           cout << endl; 
           cout << ">"; 

           cin >> choice; 
           cin.clear(); 
           cin.ignore(INT_MAX,'\n'); 

           cout << "\n"; 

           switch (choice) 
           { 
           case 1: 
                 { 
                       Town(&player); 
                       break; 
                 } 
           case 2: 
                 { 
                       //determine which level the player is on 
                       int level = 1; 
                       if (glcomplete) 
                             level = 2; 
                       else if (fcomplete) 
                             level = 3; 
                       else if (scomplete) 
                             level = 4; 

                       SummonPortal(&player,level); 
                       break; 
                 } 
           case 3: 
                 { 
                       if (!glcomplete) 
                       { 
                             if(Grasslands(&player))  
                                   glcomplete = true; 
                       } 
                       else 
                       { 
                             cout << "A wandering farmer finds your body and takes you back to town.\n\n"; 
                             Wait(); 
                             Town(&player); 
                       } 
                       break; 
                 } 
           case 4: 
                 { 
                       //if (glcomplete && !fcomplete) 
                             //Forest(); 
                       break; 
                 } 
           case 5: 
                 { 
                       //if (fcomplete && !scomplete) 
                             //Swamp(); 
                       break; 
                 } 
           case 6: 
                 { 
                       //if (scomplete && !gcomplete) 
                             //Graveyard(); 
                       break; 
                 } 
           case 7: 
                 { 
                       //if (gcomplete && !ccomplete) 
                             //Castle(); 
                       break; 
                 } 
           case 9: 
                 { 
                       DisplayStats(&player); 
                       break; 
                 } 
           case 10: 
                 { 
                       //quit 
                       break; 
                 } 
           default: 
                 { 
                       choice = -1; 
                 }break; 
           } 

     } 

     return true; 
} 

Helper.cpp

#include "Library.h"

//HELPER FUNCTIONS

void Wait()
{
    cout << "Press ENTER to continue\n"

    cin.ignore(1);
}

Global.h

#ifndef GLOBAL_DEFINE
#define GLOBAL_DEFINE

// PROTOTYPES

void Wait();
bool Crossroads();
bool Town();

#endif

and these are the erros i get when i try ot compile it:

main.cpp:4: error: '::main' must return 'int'

and just wnna say this is nt even halfway done so if theres anything incomplete thts why and thx for the help in advance :D

Recommended Answers

All 33 Replies

can you put it into the code brackets? that would be alot easier to help you.

can you put it into the code brackets? that would be alot easier to help you.

Code Start Here:

include "Library.h"void main()
{
//GENERIC WECLOME SCREEN
cout <<"\n\nWelcome to Hollow's Eye\n";
cout << "<Programmed by Ethan Rigel>\n";

cout << "Hollow's Eye a once bountiful and gorgeous land but alas; the\n";
cout << "Mighty Dragon has destroyed and ravaged our once beautiful landscape.\n";
cout << "You must rise against this evil warlord and destroy him to save our land;\n";
cout << "be careful though, for his minions roam the land searching for prey.\n\n";

Wait();

Crossroads();

cout << "\n\nThank you for playing Hollow's Eye. Please play again soon\n\n";
}


#include "Library.h"

//TOWN

bool Town()
{

int choice = 0;

while (choice != 5)
{
cout << "You walk into town.\n";
cout << "Everywhere you look you see people going about their daily lives.\n";
cout << "To your left you spot an INN and to your right an ARMORY and ITEM SHOP.\n\n";

Wait();

cout << endl;

cout << "What would you like to do\n"
cout << "1: Enter INN\n";
cout << "2: Enter ARMORY\n";
cout << "3: Enter ITEM SHOP\n";
cout << "4: Check Stats\n";
cout << "5: Leave Town\n";

cout << ">";

cin >> choice;

cout << endl;

switch (choice)
{
case 1;
{
//INN();
break;
}
case 2;
{
//ARMORY();
break;
}
case 3;
{
//ITEM SHOP();
break;
}
case 4;
{
//STATS();
break;
}
default: break;
}

}

return true;
}

#include <iostream>
using namespace std;

#include "Global.h"


Battle.cpp

//BATTLE

#include "Library.h"

bool Battle()
{
return false;
}

#include "Library.h"

//CROSSROADS

// GLOBAL VARIABLES

bool glcomplete = false;
bool fcomplete = false;
bool scomplete = false;
bool gcomplete = false;
bool ccomplete = false;

PLAYER player;


bool Crossroads()
{
//set player default values
cout << "What is your name hero?\n\n";
char name[32];
cout << ">";
cin.getline(name,32,'\n');
player.SetName(name);

cout << "\n";

int choice = 0;

while (choice != 10)
{
cout << "You stand at the center of several roads going off in many directions.\n";
cout << "There is a small town behind you full of shops and people.\n\n";

cout << "Which path do you choose?\n\n";
cout << "1: Town\n";
cout << "2: Summoning Portal\n";

if (!glcomplete)
cout << "3: Grasslands Road (QUEST)\n";

if (glcomplete && !fcomplete)
cout << "4: Forest Road (QUEST)\n";

if (fcomplete && !scomplete)
cout << "5: Swamp Road (QUEST)\n";

if (scomplete && !gcomplete)
cout << "6: Graveyard Road (QUEST)\n";

if (gcomplete && !ccomplete)
cout << "7: Castle Road (QUEST)\n";

cout << "9: View Players Stats\n";
cout << "10: Exit Game\n";

cout << endl;
cout << ">";

cin >> choice;
cin.clear();
cin.ignore(INT_MAX,'\n');

cout << "\n";

switch (choice)
{
case 1:
{
Town(&player);
break;
}
case 2:
{
//determine which level the player is on
int level = 1;
if (glcomplete)
level = 2;
else if (fcomplete)
level = 3;
else if (scomplete)
level = 4;

SummonPortal(&player,level);
break;
}
case 3:
{
if (!glcomplete)
{
if(Grasslands(&player))
glcomplete = true;
}
else
{
cout << "A wandering farmer finds your body and takes you back to town.\n\n";
Wait();
Town(&player);
}
break;
}
case 4:
{
//if (glcomplete && !fcomplete)
//Forest();
break;
}
case 5:
{
//if (fcomplete && !scomplete)
//Swamp();
break;
}
case 6:
{
//if (scomplete && !gcomplete)
//Graveyard();
break;
}
case 7:
{
//if (gcomplete && !ccomplete)
//Castle();
break;
}
case 9:
{
DisplayStats(&player);
break;
}
case 10:
{
//quit
break;
}
default:
{
choice = -1;
}break;
}

}

return true;
}


#include "Library.h"

//HELPER FUNCTIONS

void Wait()
{
cout << "Press ENTER to continue\n"

cin.ignore(1);
}


#ifndef GLOBAL_DEFINE
#define GLOBAL_DEFINE

// PROTOTYPES

void Wait();
bool Crossroads();
bool Town();

#endif


Code Ends here

ya but its easier because its color codded, all you do is there a little thing in the box where you type what your saying that says:

just press that then past the code in between there.
or just type 

Main.cpp

#include "Library.h"

void main()
{
    //GENERIC WECLOME SCREEN
    cout <<"\n\nWelcome to Hollow's Eye\n";
    cout << "<Programmed by Ethan Rigel>\n";

    cout << "Hollow's Eye a once bountiful and gorgeous land but alas; the\n";
    cout << "Mighty Dragon has destroyed and ravaged our once beautiful landscape.\n";
    cout << "You must rise against this evil warlord and destroy him to save our land;\n";
    cout << "be careful though, for his minions roam the land searching for prey.\n\n";

    Wait();

    Crossroads();

    cout << "\n\nThank you for playing Hollow's Eye. Please play again soon\n\n";
}

Town.cpp

#include "Library.h"

//TOWN

bool Town()
{

    int choice = 0;

    while (choice != 5)
    {
        cout << "You walk into town.\n";
        cout << "Everywhere you look you see people going  about their daily lives.\n";
        cout << "To your left you spot an INN and to your right an ARMORY and ITEM SHOP.\n\n";

        Wait();

        cout << endl;

        cout << "What would you like to do\n"
        cout << "1: Enter INN\n";
        cout << "2: Enter ARMORY\n";
        cout << "3: Enter ITEM SHOP\n";
        cout << "4: Check Stats\n";
        cout << "5: Leave Town\n";

        cout << ">";

        cin >> choice;

        cout << endl;

        switch (choice)
        {
            case 1;
                {
                    //INN();
                    break;
                }
            case 2;
                {
                    //ARMORY();
                    break;
                }
            case 3;
                {
                    //ITEM SHOP();
                    break;
                }
            case 4;
                {
                    //STATS();
                    break;
                }
        default: break;
        }

    }

    return true;
}

Library.h

#include <iostream>
using namespace std;

#include "Global.h"

Crossrodas.cpp

#include "Library.h" 
 
//CROSSROADS 
 
// GLOBAL VARIABLES 
 
bool glcomplete = false; 
bool fcomplete = false; 
bool scomplete = false; 
bool gcomplete = false; 
bool ccomplete = false; 
 
PLAYER player; 
 
 
bool Crossroads() 
{ 
//set player default values 
     cout << "What is your name hero?\n\n"; 
     char name[32]; 
     cout << ">"; 
     cin.getline(name,32,'\n'); 
     player.SetName(name); 
 
     cout << "\n"; 
 
     int choice = 0; 
 
     while (choice != 10) 
     { 
           cout << "You stand at the center of several roads going off in many directions.\n"; 
           cout << "There is a small town behind you full of shops and people.\n\n"; 
 
           cout << "Which path do you choose?\n\n"; 
           cout << "1: Town\n"; 
           cout << "2: Summoning Portal\n"; 
 
           if (!glcomplete) 
                 cout << "3: Grasslands Road (QUEST)\n"; 
 
           if (glcomplete && !fcomplete) 
                 cout << "4: Forest Road (QUEST)\n"; 
 
           if (fcomplete && !scomplete) 
                 cout << "5: Swamp Road (QUEST)\n"; 
 
           if (scomplete && !gcomplete) 
                 cout << "6: Graveyard Road (QUEST)\n"; 
 
           if (gcomplete && !ccomplete) 
                 cout << "7: Castle Road (QUEST)\n"; 
 
           cout << "9: View Players Stats\n"; 
           cout << "10: Exit Game\n"; 
            
           cout << endl; 
           cout << ">"; 
            
           cin >> choice; 
           cin.clear(); 
           cin.ignore(INT_MAX,'\n'); 
 
           cout << "\n"; 
 
           switch (choice) 
           { 
           case 1: 
                 { 
                       Town(&player); 
                       break; 
                 } 
           case 2: 
                 { 
                       //determine which level the player is on 
                       int level = 1; 
                       if (glcomplete) 
                             level = 2; 
                       else if (fcomplete) 
                             level = 3; 
                       else if (scomplete) 
                             level = 4; 
 
                       SummonPortal(&player,level); 
                       break; 
                 } 
           case 3: 
                 { 
                       if (!glcomplete) 
                       { 
                             if(Grasslands(&player))  
                                   glcomplete = true; 
                       } 
                       else 
                       { 
                             cout << "A wandering farmer finds your body and takes you back to town.\n\n"; 
                             Wait(); 
                             Town(&player); 
                       } 
                       break; 
                 } 
           case 4: 
                 { 
                       //if (glcomplete && !fcomplete) 
                             //Forest(); 
                       break; 
                 } 
           case 5: 
                 { 
                       //if (fcomplete && !scomplete) 
                             //Swamp(); 
                       break; 
                 } 
           case 6: 
                 { 
                       //if (scomplete && !gcomplete) 
                             //Graveyard(); 
                       break; 
                 } 
           case 7: 
                 { 
                       //if (gcomplete && !ccomplete) 
                             //Castle(); 
                       break; 
                 } 
           case 9: 
                 { 
                       DisplayStats(&player); 
                       break; 
                 } 
           case 10: 
                 { 
                       //quit 
                       break; 
                 } 
           default: 
                 { 
                       choice = -1; 
                 }break; 
           } 
 
     } 
 
     return true; 
} 


]

Battle.cpp

//BATTLE

#include "Library.h"

bool Battle()
{
    return false;
}

Helper.cpp

#include "Library.h"

//HELPER FUNCTIONS

void Wait()
{
    cout << "Press ENTER to continue\n"

    cin.ignore(1);
}

Global.h

#ifndef GLOBAL_DEFINE
#define GLOBAL_DEFINE

// PROTOTYPES

void Wait();
bool Crossroads();
bool Town();

#endif

Here is this good? Srry im new to these forums..

looks pretty good to me, but i have a couple questions.

how did you do your: press enter to continue thing, and do you know how to do random numbers? im working on a rpg game myself. if you want send me a private message and we can work on one together.

>> and these are the erros i get when i try ot compile it:
>> main.cpp:4: error: '::main' must return 'int'

See Should I use void main() or int main()?

thx tht helped for that error but now it's givng me more errors.

this is wht my build log said:

C:/Documents and Settings/Owner/Desktop/Rpg Game/main.cpp:15: undefined reference to `Wait()'
C:/Documents and Settings/Owner/Desktop/Rpg Game/main.cpp:17: undefined reference to `Crossroads()'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 0 warnings


and i am using code Blocks comlier don't know if that matters or not.

and skorm im just acutally following a tutorial and just learniing the basics but that would be cool to work on one when i get more expeirenced.

>> undefined reference to `Wait()'

In Code::Blocks, be sure to add the Helper.cpp file ( Wait() is defined there) to your project and rebuild. Do the same with the file containing Crossroads() .

The compiler is not seeing the definitions of these two functions at the moment.

>> undefined reference to `Wait()'

In Code::Blocks, be sure to add the Helper.cpp file ( Wait() is defined there) to your project and rebuild. Do the same with the file containing Crossroads() .

The compiler is not seeing the definitions of these two functions at the moment.

thx tht helped again but for some reason some more errors have popped up when i try to build it now it says:


Compiling: main.cpp
In file included from C:\Documents and Settings\Owner\Desktop\Rpg Game\main.cpp:3:
C:\Documents and Settings\Owner\Desktop\Rpg Game\Helper.cpp: In function 'void Wait()':
C:\Documents and Settings\Owner\Desktop\Rpg Game\Helper.cpp:10: error: expected ';' before 'cin'
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings

>> error: expected ';' before 'cin'

The compiler seems to be spot-on here, you really need to add a semicolon before cin as suggested.
;)

>> error: expected ';' before 'cin'

The compiler seems to be spot-on here, you really need to add a semicolon before cin as suggested.
;)

i tried but i don't know where to put it :( i tried to put it before cin itself an then i tried to put it after cout << "Press ENTER to continue\n" but it doesnt work?

That sounds confusing, I think the following should do ..

#include "Library.h"

//HELPER FUNCTIONS

void Wait()
{
    cout << "Press ENTER to continue\n" ; // <--- added semicolon

    cin.ignore(1);
}

That sounds confusing, I think the following should do ..

#include "Library.h"

//HELPER FUNCTIONS

void Wait()
{
    cout << "Press ENTER to continue\n" ; // <--- added semicolon

    cin.ignore(1);
}

i tried that it doesn't work and it also says theres something worng with
void Wait() may tht be the problem?

>> i tried that it doesn't work

So, you are getting a compiler error?

>> i tried that it doesn't work

So, you are getting a compiler error?

yeah the compiler says somethign is wrong

>> yeah the compiler says somethign is wrong

I see, could you post the error message?

>> yeah the compiler says somethign is wrong

I see, could you post the error message?

heres all it says on the build log


In file included from C:\Documents and Settings\Owner\Desktop\Rpg Game\main.cpp:3:
C:\Documents and Settings\Owner\Desktop\Rpg Game\Helper.cpp: In function 'void Wait()':
C:\Documents and Settings\Owner\Desktop\Rpg Game\Helper.cpp:10: error: expected ';' before 'cin'
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings

Hmm, this is going round in circles, I'm having hard time in believing that the semicolon is there properly placed (see the above post) -- could you post the helper.cpp file again?

Hmm, this is going round in circles, I'm having hard time in believing that the semicolon is there properly placed (see the above post) -- could you post the helper.cpp file again?

#include "Library.h"

//HELPER FUNCTIONS

void Wait()
{
    cout << "Press ENTER to continue\n"

    cin.ignore(1);
}

#include "Library.h"

//HELPER FUNCTIONS

void Wait()
{
cout << "Press ENTER to continue\n" <----- doesnt work when i put there

or here -----> cin.ignore(1);
}

Aha .. as a matter of the fact, you absolutely have to put that semicolon there i.e.

#include "Library.h"

//HELPER FUNCTIONS

void Wait()
{
    cout << "Press ENTER to continue\n" ; // <--- semicolon required by C++

    cin.ignore(1);
}

Now, be sure to use the above helper.cpp and rebuild -- what happens?

Aha .. as a matter of the fact, you absolutely have to put that semicolon there i.e.

#include "Library.h"

//HELPER FUNCTIONS

void Wait()
{
    cout << "Press ENTER to continue\n" ; // <--- semicolon required by C++

    cin.ignore(1);
}

Now, be sure to use the above helper.cpp and rebuild -- what happens?

ok i did and here is wht happens

In file included from C:\Documents and Settings\Owner\Desktop\Rpg Game\main.cpp:3:
C:\Documents and Settings\Owner\Desktop\Rpg Game\Helper.cpp: In function 'void Wait()':
C:\Documents and Settings\Owner\Desktop\Rpg Game\Helper.cpp:10: error: expected ';' before 'cin'
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings

heres the code

#include "Library.h"

//HELPER FUNCTIONS

void Wait()
{
    cout << "Press ENTER to continue\n";

    cin.ignore(1);
}]

>> ok i did and here is wht happens

Duh, something is amiss here, you might as well zip the project (*.h, *cpp) and post it as an attachment.

>> ok i did and here is wht happens

Duh, something is amiss here, you might as well zip the project (*.h, *cpp) and post it as an attachment.

Here

Here

srry for some reason tht last one was corrupt

this one will hopefully work

Alright, your project includes only the main.cpp file, through which you try to include another source file -- that is wrong. Generally, only include .h files in .cpp files.

Basically you want to add your source and header files to your Code::Blocks project so that they are visible in the Manager View. Then, when you build the project, the source files will get compiled (without being included anywhere). When setting up the project, try to do it in manageable steps (read: your code compiles), instead of adding everything at once and having maybe a hundred errors or so.

As to the semicolon-problem you are having, I cannot reproduce it (compiling your project as-is) - the only error was about undefined reference to Crossroads() , which is correct.

Alright, your project includes only the main.cpp file, through which you try to include another source file -- that is wrong. Generally, only include .h files in .cpp files.

Basically you want to add your source and header files to your Code::Blocks project so that they are visible in the Manager View. Then, when you build the project, the source files will get compiled (without being included anywhere). When setting up the project, try to do it in manageable steps (read: your code compiles), instead of adding everything at once and having maybe a hundred errors or so.

As to the semicolon-problem you are having, I cannot reproduce it (compiling your project as-is) - the only error was about undefined reference to Crossroads() , which is correct.

thx for the help now i see what was wrong :D

thx for the help now i see what was wrong :D

now i have one more problem then it will run

heres the code :

#include "Library.h"

//HELPER FUNCTIONS

void Wait()
{
    cout << "Press ENTER to continue\n";

    cin.ignore(1);
}

heres the errors:

Compiling: main.cpp
Linking console executable: bin\Debug\Rpg Game.exe
obj\Debug\main.o: In function `Z4Waitv':
C:/Documents and Settings/Owner/Desktop/Hollow's Eye/Helper.cpp:7: multiple definition of `Wait()'
obj\Debug\Helper.o:C:/Documents and Settings/Owner/Desktop/Hollow's Eye/Helper.cpp:7: first defined here
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 0 warnings

>> multiple definition of `Wait()'

This suggests that you have the statement #include "Helper.cpp" in one or more files -- you DON'T want to #include .CPP files.

>> multiple definition of `Wait()'

This suggests that you have the statement #include "Helper.cpp" in one or more files -- you DON'T want to #include .CPP files.

:) thx for the help i finally got it running lets consider this thread CLSOED

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.