Reputation: 9575
I'm trying to design a simple snake game. Here is my code:
using namespace std;
bool gameOver;
//Map Dimentions
const int width = 20;
const int height = 20;
//Positions
int x, y, fruitX, fruitY, score;
//Directions
enum eDirection { STOP = 0, Left, Right, Up, Down};
eDirection dir;
void Setup() {
gameOver = false;
dir = STOP;
//Center Snake Head
x = width / 2;
y = height / 2;
//Randomly places fruit within constraints of map
fruitX = rand() % width;
fruitY = rand() % height;
score = 0;
}
void Draw() {
//Clears Terminal Window
system("clear");
//Walls of Map
for(int j = 0 ; j < height ; ++j)
{
for(int i = 0; i < width ;++i)
{
if( i == 0 || i == (width - 1) || j == 0 || j == (height - 1) )
{
cout << "* ";
}
else
{
cout << " ";
}
}
cout << endl;
**}**
}
void Input() {
}
void Logic() {
}
int main () {
Setup();
while (!gameOver) {
Draw();
Input();
Logic();
}
return 0;
}
At the beginning of my code document, I have all c++ libraries included. On the last } of my Walls of Map, surrounded in ****'s, I receive the error " Use of undeclared identifier " ". I have no idea what could be causing this. Any ideas?
Upvotes: 0
Views: 350
Reputation: 33982
To test a theory, I pulled up the file in an antique text editor and I see
**}?**
Hex editor says
20 20 20 20 2A 2A 7D 3F 2A 2A
That 3F shouldn't be there.
Upvotes: 1