Sign in to follow this  
emforce

Random error? (and engine help :D)

Recommended Posts

hi guys i have decided to have a bash at creating my own game engine but i seem to be coming up against some stupid error. C2143 syntax error : missing ';' before '{' here is my game engine so far(dont laugh i started it about 15 minutes ago and spent 10 minutes looking for an answer -.- )
#include <iostream>


/*--------------------
global variables
--------------------*/

char NewGame;
char menu_choice;


/*---------------------
game engine functions 
-----------------------*/
void intro();
void menu();
void GameStart();
void game();


int main()
{

	using namespace std;
	intro();
	menu();

	/*--------------------
	game loop
	------------------*/

	do
	{
		GameStart();
	}while (NewGame == 'y' || NewGame == 'Y');



	cin.get();
	cin.get();
	return 0;
}
void intro()
{
	using namespace std;
	cout << " hello and welcome! ";
	cout << "\n If at any time you want to quit please press q ";

}
void menu()
{
	

	std::cout << " \nNew Game <Y/N> \n";
	std::cout << "1- Updates \n" 
		<< "2- about \n"
		<< "3- help \n";
	std::cin >> NewGame;

	
	std::cin >> menu_choice;
	while (menu_choice == 'y' || menu_choice == 'Y')
	{
		Game();


	}
	
	switch (menu_choice)
	{
		case '1' :
			std::cout << "\n This is my very first text game engine \n";
			break;
		case '2' :
			std::cout << "\n This is a simple game engine ";
			break;
		case '3' :
			std::cout << "\n to start playing a game please enter <Y> ";
			break;
		default:
			std::cout << "";
			break;

	}
	
	
	


}
void GameStart()
{
	using std::cout;

	cout << "\n Hello and welcome!";

}
void Game()
{
	using namespace std;

	/* -----------------
	game variables
    ----------------*/
	int player_health;
	int monster_health;

	cout << endl;
	cout << " You are a knight walking to jerusalem! " << endl;
	cout << " when suddenly you are attacked by a saracen! " << endl;
	


}




please help oh and btw can u give me any advice on my program and what i should add to it? * btw i didn't use classes in this because as it is a very simple text based engine i couldn't be bothered implementing it [Edited by - emforce on June 19, 2009 6:01:28 PM]

Share this post


Link to post
Share on other sites
I'm very cautios about how I approach a post like this so please don't take it as me raining on someones parade but I need to be frank. You're a beginner, yes? Why a game engine?

To bring this around and to (hopefully) appear as being positive and constructive, you need to crawl before you can walk and you need to walk before you can run. Developing a game engine isn't easy and it's not trivial either. Getting caught up on a basic pitfall like what you posted is evidence of that. (note that I'm not critisizing your skill -- we all started somewhere and believe me I've had my shaer of whoppers).

To that end, you should start with something a lot less complicated. As it seems that you're going for the CLI, you've got a couple of options. Try a classic text adventure game. I have a beginning programmer on my team and he came up with a turn-based battle type game called "The Mutated Garden". It's a bit of a story so I won't get into it but it's also text-based.

If you want to get into graphical games, you're best bet is to start with SDL. It has a section with tutorials (I personally liked the Cone3D Marius tutorials) to get you started off learning how to work with SDL. From there you can develop simple games and then continue on to learn how to program game engines.

A good way to learn how engines are developed is to look at existing examples. My first engine was an RPG engine way back in 1996 when DOS was still a viable gaming environment (albeit waning but it worked). Before that I had worked with DooM and DooM2 making maps, editing WAD's and so on so I had a pretty good understanding of how engines generally worked. Not too long afterward id released the source code for Quake and that's when I learned how a commercial game engine was developed (and later Quake2 which isn't too much different from Quake, surprisingly enough).

You can also join existing game projects that are in active development willing to accept beginner programmers. You'd be surprised just how many such projects exist. Learning from more experienced programmers is probably the most effective way to really learn the tricks of the trade. If that's not an option there are always tutorials all over the web. Google is your friend in this case and I've read my fair share of tutorials. Also look for 'software engineering' articles because programming is a lot less of an art form than many programmers are likely to tell you (I'm risking a flame war here so please accept that this is my humble opinion and that such a debate is not appropriate in this thread).

Lastly, I just want to point out that you're not going to be starting on a game engine and seeing results in a month. Look for at least six months and as long as a year or two. Yes, it really takes that long to become proficient in C++ and game development in general.

I hope all of this helps. Good luck!

[EDIT]
I wanted to respond to your comment about not wanting to be bothered with classes. You really should reconsider because by ignoring classes you're effectively turning your back on exactly what makes C++ so amazing in the first place. You're also not learning how to properly implement and use classes and if you're going to be an effective C++ programmer you're going to need to know how to properly use them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this