I'm pretty new to c++, I've only been doing it a short time, so I'm not entirely sure whats wrong with this program.
I've looked over notes I have about functions and variables, and it all seems correct. I'm not sure what exactly the problem is, but I hope someone can help ^^
I'm trying to make a 'game' purely out of cout, cin and only basic functions.
Code:
/*
Name: Text Based RPG Game
Author: Tony Jordan
Date: 29/03/06 14:06
Description: A text based game made comprising purely of basic C++ features, such as cin, cout and filestreams.
Some minor math (addition, subtraction, random numbers) are present.
*/
#include <iostream>
#include <string>
#include <fstream>
#include <conio.h>
#include <math.h>
using namespace std;
//FUNCTIONS
//NEW GAME
void NewGame(void)
{
cout << "New Game Starting!";
getch();
}
//LOAD GAME
void LoadGame(void)
{
cout << "Loading";
getch();
}
//QUIT GAME
void Exit(void)
{
char quit;
cout << "Are you sure you want to quit?" << endl;
cin >> quit;
if ((quit=='Y') || (quit=='y'))
{
cout << "Quitting" << endl;
}
}
//ABOUT
void About(void)
{
cout << "Name: Text Based RPG Game" << endl;
cout << "Author: Tony Jordan" << endl;
cout << "Date: 29/03/06 14:06" << endl;
cout << "Contact Email: [email protected]" << endl;
}
int Menu(void)
{
int option;
cout << "*******************************************************************" << endl;
cout << "*******************************************************************" << endl;
cout << "************************* [GAME NAME HERE] ************************" << endl;
cout << "*******************************************************************" << endl;
cout << "*******************************************************************" << endl;
cout << endl;
cout << endl;
cout << " --Menu--" << endl;
cout << " Please enter a menu choice to begin." << endl;
cout << "1. Start a New Game" << endl;
cout << "2. Load an Existing Game" << endl;
cout << "3. About" << endl;
cout << "4. Exit the Game" << endl;
cin >> option;
while ((option < 1) || (option > 4))
{
cout << endl;
cout << "Not a valid option. Try again" << endl;
cin >> option;
}
return option;
}
//Constants
//Variables
//Player Variables
/*
HP is Players Current HP
MaxHP is Players Maximum HP
MP is Players Current MP
MaxMP is Players Maximum MP
Str is players strength/attack power
Def is players defensive ability
Mag is players Majik
MagDef is players Majik Defence
Level is players Level (1, 2, 3, etc)
EXP is the amount of experience player has
EXPTNL is amount of experience player needs to level up, when EXP == EXPTNL, player gains 1 level.
Job is players Job name
Name[16] is players name, maximum 15 characters long
*/
int HP, MaxHP, MP, MaxMP, Str, Def, Mag, MagDef, Level, EXP, EXPTNL;
char Name[16], Job;
//General Variables
/*
Choice is the menu choice
*/
int choice;
//MAIN
int main(void)
{
do
{
choice=Menu();
if (choice == 1)
{
NewGame();
}
else if (choice==2)
{
LoadGame();
}
else if (choice==3)
{
About();
}
} while (choice != 4);
}
return 0;
}
I get these errors when I try to compile it:
C:\Documents and Settings\Tony\My Documents\bored\main.cpp:140: error: expected unqualified-id before "return"
C:\Documents and Settings\Tony\My Documents\bored\main.cpp:140: error: expected `,' or `;' before "return"
C:\Documents and Settings\Tony\My Documents\bored\main.cpp:141: error: expected declaration before '}' token
If it help's at all, I'm using Bloodshed Dev C++ 4.9.9.2 on Windows XP.
Many Thanks in Advance