Well, it isn't really good enough to be considered an actual game - it's just a battleship and rocketship program I made for a teacher last December (in Pascal) to enter guesses for the location and display the distance from the guess to the actual location. For extra credit that I desperately need in my Visual C++ class (stupid teacher >:/), I began to reprogram this in C++.

After finding out that I couldn't do graphics like I had wanted to, I just went to using output and ASCII art to make something display. Except it won't display, as it doesn't make it through the compiler.

I've got three problems with it: The arrays used for the coordinates, this funky loop, and it seems to have a beef with my coordinate-generating function for the rocketship. (3 variables.)

Ok, first, the arrays.

I had written it to use arrays as the coordinate values, to simplify on the number of variables. So I have four arrays: Two boolean two-dimensional arrays, for the battleship's actual coordinates and the guess for the battleship's coordinates, then two boolean three-dimensional arrays for the rocket's coordinates and the guess for the rocket coordinates. But no matter how I try I can't get them to cooperate with the compiler... their use with the functions is what's going wonky. Here's the relevant array code:

This is where it errors, the calling of the function, where it either gives a syntax error if X isn't there, and a can't convert 'bool' to 'bool'(*)[10] error if there is something there:Code:`//Define the boolean values`

const int True = 1;

const int False = 0;

//Define the arrays for the grid

const int GRID_SIZE = 10;

typedef bool list_BSCoords[GRID_SIZE] [GRID_SIZE];

list_BSCoords BSCoords;

typedef bool list_BSGuessCoords[GRID_SIZE] [GRID_SIZE];

list_BSGuessCoords BSGuessCoords;

typedef bool list_RSCoords[GRID_SIZE] [GRID_SIZE] [GRID_SIZE];

list_RSCoords RSCoords;

typedef bool list_RSGuessCoords[GRID_SIZE] [GRID_SIZE] [GRID_SIZE];

list_RSGuessCoords RSGuessCoords;

void BSrng(bool BScoords[GRID_SIZE] [GRID_SIZE], int &XCoord, int &YCoord);

void RSrng(bool RScoords[GRID_SIZE] [GRID_SIZE] [GRID_SIZE], int &XCoord, int &YCoord, int&ZCoord);

Code:`bool X; //Dummy variable to call the function`

X = 0;

BSrng(BSCoords[X] [X], XCoord, YCoord); //randomize the battleship coordinates

And then, it's giving me all kinds of wierd errors within this do while loop in the battleship's game function:Code:`BSrng(bool BSCoords[GRID_SIZE] [GRID_SIZE], int &XCoord, int &YCoord);`

{ //Seed the random numbers

time_t seconds;

time(&seconds);

srand((unsigned int) seconds);

//Assign random values for the coordinates

XCoord = rand() % (High - Low + 1) + Low;

YCoord = rand() % (High - Low + 1) + Low;

//"Input" corresponding coordinates into the array

BSCoords[XCoord] [YCoord] = True;

}

The errors are as follows:Code:`do`

{ cout << "X Coordinate?" << endl;

cin >> XGuess; //read in an X-coordinate guess

cout << "Y Coordinate?" << endl;

cin >> YGuess; //read in a Y-coordinate guess

BSGuessCoords[XGuess] [YGuess] = True; //Assign corresponding array to hit

If ((XGuess == 0) && (YGuess == 0))

quit = True;

Else If (BSGuessCoords[XGuess] [YGuess] && BSCoords[XGuess][YGuess])

{ cout << "You sunk my battleship!" << endl;

cout << "It took you " << counter << " tries to hit my battleship." << endl;

}

Else

{ ++counter;

distance = sqrt((XCoord - XGuess)^2 + (YCoord - YGuess)^2)

cout << "You missed me by " << setiosflags(ios::showpoint|ios::fixed)

<< setprecision(2) << distance << endl;

}

} while (!exit);

Call to undefined function 'If' (statement line with if requires ;)

Undefined symbol 'Else' (statment line with else requires ;)

do statement must have while.

And finally, the rocket function coordinate generator:

Expression syntax on the function's header lineCode:`RSrng(bool RSCoords[GRID_SIZE] [GRID_SIZE] [GRID_SIZE], int &XCoord, int &YCoord, int &ZCoord);`

{ //Seed the random numbers

time_t seconds;

time(&seconds);

srand((unsigned int) seconds);

//Assign random values for the coordinates

XCoord = rand() % (High - Low + 1) + Low;

YCoord = rand() % (High - Low + 1) + Low;

ZCoord = rand() % (High - Low + 1) + Low;

//"Input" corresponding coordinates into the array

RSCoords[XCoord] [YCoord] [ZCoord] = True;

}

Undefined symbol 'ZCoord' (which I had declared exactly as all the others in the rocket function) and

Compound statement missing } at the end of the function.

Please, someone help me out here... I hope so very much that it isn't anything serious, and that I can get it done before Thursday... (Teacher doesn't have the slightest clue why it's not working)