|
Ok, that's the code I have in so far. There is only 1 error, On line 117, it says, "parse error before '*'"
112: void gameLoop()
113: {
114:
115: for(;;)
116: {
117: commands(char *com, char *obj);
118: }
119: }
|
|
I don't see whats wrong with it. I have typed it and retyped it over and over, changed the names, ex: comm(char *command, char *obj); and it still gives me that exact error. It seems that whenever I type in that one line, I have an error before the '*'... If I delete the stuff between the (), and just put a coma, it will then say, "parse error before ';'"
Please help me,
Will
#include <iostream.h>
//#include <conio_mingw.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <conio.c>
#define DRK_BLUE 1
#define DRK_GREEN 2
#define DRK_CYAN 3
#define DRK_RED 4
#define DRK_PURPLE 5
#define DRK_YELLOW 6
#define DRK_WHITE 7
#define GREY 8
#define BLUE 9
#define GREEN 10
#define CYAN 11
#define RED 12
#define PURPLE 13
#define YELLOW 14
#define WHITE 15
char msg(int color, char *str);
void start();
void stats();
void gameLoop();
int damage();
void commands(char *com, char *obj);
void move(char *dir);
void say(char *said);
struct player
{
char name[15];
int hp;
int max_hp;
int mana;
int max_age;
int age;
int x;
int y;
};
struct equip
{
int arm;
int leg;
int chest;
int head;
};
struct weapon
{
int minDam;
int maxDam;
};
player char_;
equip eq;
weapon weap;
int main()
{
start();
}
void start()
{
cout<<"Welcome to Will Sayin's Game"<<endl;
cout<<"By what name would you like to be known?";
cin>> char_.name;
int namelength;
namelength = strlen(char_.name); //certain length restrictions
if(namelength > 15)
{
cout<<"Name too long, try again."<<endl;
start();
}
if(namelength <3)
{
cout<<"Name too short, try again."<<endl;
start();
}
cout<<"Hello, "<<char_.name<<". How old are you?"<<endl;
cin>>char_.age;
stats(); //roll stats
}
void stats()
{
cout<<"Rolling base stats...\n\n"<<endl;
char_.hp = rand() %50 + 30;
char_.mana = rand() %100 +70;
cout<<char_.hp<<"hp ||"<<char_.mana<<" mana."<<endl;
msg(WHITE, "is this acceptable?y/n");
char yesno;
cin>>yesno;
if(yesno == 'Y'||yesno == 'y')
{
gameLoop();
}
else
{
msg(WHITE, "rerolling...");
stats();
}
}
void gameLoop()
{
for(;;)
{
commands(char *com, char *obj);
}
}
char msg(int color, char *str)
{
textcolor(color);
cout<<str<<endl;
textcolor(WHITE);
}
void commands(char *com, char *obj)
{
if(com == "go")
{
move(obj);
}
else if(com =="say")
{
say(obj);
}
else
{
msg(WHITE, "Invalid Command.");
gameLoop();
}
}
void move(char *dir)
{
if(dir == "north" || dir == "n")
{
char_.y--;
msg(YELLOW, "You move north.");
gameLoop();
}
else if(dir == "south" || dir == "s")
{
char_.y++;
msg(YELLOW, "You move south.");
gameLoop();
}
else if(dir == "east" || dir == "e")
{
char_.x++;
msg(YELLOW, "You move east.");
gameLoop();
}
else if(dir == "west" || dir == "w")
{
char_.x--;
msg(YELLOW, "You move west.");
gameLoop();
}
else
{
msg(RED, "No exit that direction.");
gameLoop();
}
}
void say(char *said)
{
cout<<"You say, '"<<said<<"'"<<endl;
}
|
|
|
|
|
Hi,
I really do not know that what you are trying to do over there. The code can be something like this....
void gameLoop()
{
char com[256];//you can allocate statically or dynamically
char obj[256];
for(;;)
{
cout << endl << "Enter the command";
cin>> com;
cout << endl << "Enter the obj"
cin>> obj;
commands(com,obj);
}
}
|
|
|
|
|
|
|
|