C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 04-01-2006, 03:18 PM   #1
Registered User
 
Join Date: Nov 2005
Posts: 11
Exclamation Game Won't Compile

I am currently making a C++ text-based adventure game (without classes! -- I'll learn later). I've had some compiler errors before, but I've always fixed them. This time, however, the problem is much more complex. I see nothing wrong with my code, and I tried reinstalling Microsoft Visual C++ Express 2005 to no avail. The errors started when I added a few more functions to my game. Since I have a template I use for all my functions, that's not the problem. The following is my entire header file and my function template. Sorry for the badly formatted comments!

Code:
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;

// Global Application

int main();
int menu();		// Function	Menu
int abvh();	//	About + Version History
int intr1();                //			Name
int intr2();	//			Health
int contr();               //			Controls
int links();		//			Links
int debug();	//			Debug
int udbg1;	// Variable	Debug Accessibilty
bool udbg2;	//	Debug Selection
bool unme3;	//	Name Confirmation
bool unme4;	//	Name Confirmation
bool uhlh2;	//Health
string uexit;	//	Exit 
string unme1;	//	Name
string unme2;	//	Name Confirmation
string uhlth;	//	Health
string umenu;	//	Menu Number

// Global Actions

string ufact;	// Variable	Action	Fight
string ugact;	//	Game
string uiact;            //	Inventory
string udact;	//	Debug

// Global Game

int gintr();	// Function	Level Introduction
int fight();		//			Fight
int inven();	//			Inventory
const int cappl = 3;	// Variable	Apple Cost
const int cpens = 2;	//			Pen Cost
const int happl = 3;	//			Healing Apple
const int helix = 5;	//			Healing Elixir
int ccont = 1;	//		Level Completion Count
int udied;		//			Death Count
int inews;		//		Inventory	Newspaper
int iciga;	               //		Pack of Cigarettes
int iiden;		//		ID
int ijakt;		//		Jacket
int iappl;		//		Apple
int ipens;		//		Pens
int ikey1;		//		Peculiar House Key
int ielix;		//		Elixir
int irsdg;		//		Rusty Dagger
int ipofa;		//		Poison Fang
int ibamm;	//	Boxing Arena Membership
int ileat;		//			Leather
int ename;	//		Fight	Enemy Name
int umndg;	//		User Minimum Damage
int umxdg;	//		User Maximum Damage
int emndg;	//		Enemy Minimum Damage
int emxdg;	//		Enemy Maximum Damage
int umndf;	//		User Minimum Defense
int umxdf;		//		User Maximum Defense
int emndf;	//		Enemy Minimum Defense
int emxdf;	               //		Enemy Maximum Defense
int rgold;		//		Random Gold
int cheff;		//		Chance of Effect
int ustdr;		//	User Status Effect Duration
int estdr;		//	Enemy Status Effect Duration
int dstef;		//	Damage of Status Effect
float uheal = 50;	//			Your Health
float money = 10;	//			Money
float dmage;	//			Fight Damage
float dfens;	//			Defense
float eheal;	//			Enemy Health
string enamc;	//		Enemy Display Name
string eefct;	//		Enemy Effect
string uefct;	//		User Effect
string ustef;	//		User Status Effect
string estef;             //		Enemy Status Effect
string uweap;	//		Equipped Weapon
string uarmr;            //		Equipped Armor

// Level 1

int l1gp1();	// Function	Glen Park 1
int l1gp2();	//		Glen Park 2
int l1hs1();              //		Howard Street 1
int l1br1();	//			Bar 1
int l1br2();	//			Bar 2
int l1ii1;		// Variable Interaction	Item 1
int l1pe1;		//		Person 1
int l1pe2;	                //		Person 2
int l1pe3;		//		Person 3

// Level 2

int l2db1();	// Function	Domenic Boulevard 1
int l2db2();	//		Domenic Boulevard 2
int l2de1();               //			Depanneur 1
int l2ho1();	//			Shack Door
int l2ho2();	//			Shack Kitchen
int l2ho3();	//			Shack Closet
int l2ba1();	//		Belgrave Avenue 1
int l2sl1();	//		Symmetric Lane 1
int l2hs1();	//		Howard Street 1
int l2ii1;		// Variable Interaction	Item 1
int l2ii2;		//			Item 2
int l2pe1;		//			Person 1
int l2pe2;		//			Person 2
int l2pe3;		//			Person 3
string ul2b1;	//		Depanneur Selection

// Level 3

int l3vs1();	// Function	Victoria Square 1
int l3wa1();	//			Werd Alley 1
int l3sw1();	//			Sewers 1
int l3ch1();	//			City Hall 1
int l3ba1();	//			Boxing Arena 1
int l3ba2();	//			Boxing Arena 2
int l3er1();	//			Echo Road 1
int l3rb1():	//			Royal Bank 1
/*1*/int l3am1();	//			Amunation 1
/*2-3*/int chlvl;	// Variable	Challenger Level
int l3pe1;		//	Interaction	Person 1

/* adding l3er1, rb1, am1, and l3pe1 made the compiler go crazy. perhaps there's a limit to the number of functions you can have?*/

/*

int ?() {
	do {
		ugact = "";
		system ( "cls" );
		cout << "?" << endl;
		cout << "?" << endl;
		cout << "What do you do? ";
		getline (cin, ugact);
		if (udied == 5)
			return 0;
		if (ugact == "i")
			inven();
		cin.get();
		if (ccont == ?)
			return 0;
	} while (ugact != "?");
	return 0;
}

*/
Errors: (associated with numbers in comments in code)

1-header.h(126) : error C2062: type 'int' unexpected
2-header.h(127) : error C2062: type 'int' unexpected
3-header.h(127) : error C2630: ';' found in what should be a comma-separated list
main.cpp(3) : error C2062: type 'int' unexpected [ when clicked, transports you to : int main() { ]
main.cpp(3) : error C2630: ';' found in what should be a comma-separated list [ see above comment ]
main.cpp(791) : error C2065: 'l3pe1' : undeclared identifier
main.cpp(894) : error C2065: 'chlvl' : undeclared identifier
main.cpp(942) : error C3861: 'l3am1': identifier not found
main.cpp(952) : error C2084: function 'int l3rb1(void)' already has a body
header.h(125) : see previous definition of 'l3rb1'
main.cpp(972) : error C2365: 'l3am1' : redefinition; previous definition was 'formerly unknown identifier'

this warning has always been there -- it's not important
main.cpp(991) : warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
jothesmo is offline   Reply With Quote
Old 04-01-2006, 04:15 PM   #2
Frequently Quite Prolix
 
dwks's Avatar
 
Join Date: Apr 2005
Location: Canada
Posts: 7,698
Quote:
this warning has always been there -- it's not important
main.cpp(991) : warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
That would mean you went
Code:
srand(time(0));
To get rid of that warning, use
Code:
srand((unsigned)time(0));
Darn that shift key, eh?
Code:
int l3er1();	//			Echo Road 1
int l3rb1():	//			Royal Bank 1
/*1*/int l3am1();	//			Amunation 1
Do you see it now?
Code:
int l3rb1(): 
Code:
(): 
Code:
: 
That should be a semicolon.
__________________
dwk

Seek and ye shall find. quaere et invenies.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell


Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net

My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
dwks is offline   Reply With Quote
Old 04-01-2006, 04:24 PM   #3
Registered User
 
Join Date: Nov 2005
Posts: 11


My eyes must be very bad; I looked twice to see if I had put any colons and still didn't see my mistake!

Thanks!
jothesmo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Open-source Game Project Glorfindel Projects and Job Recruitment 0 03-24-2009 01:12 AM
20q game problems Nexus-ZERO C Programming 24 12-17-2008 05:48 PM
So you want to be a game programmer? dxfoo Game Programming 23 09-26-2006 08:38 AM
HELP!wanting to make full screen game windowed rented Game Programming 3 06-11-2004 04:19 AM
My Maze Game --- A Few Questions TechWins Game Programming 18 04-24-2002 11:00 PM


All times are GMT -6. The time now is 02:39 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22