gpt4 book ai didi

c++ - 在简单的蛇游戏中使用未声明的标识符错误

转载 作者:行者123 更新时间:2023-11-28 05:17:13 27 4
gpt4 key购买 nike

我正在尝试设计一个简单的贪吃蛇游戏。这是我的代码:

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;
}

在我的代码文档的开头,我包含了所有的 C++ 库。在我的 map 墙的最后一个 } 中,被 **** 包围,我收到错误“使用未声明的标识符”“。我不知道是什么导致了这个。有什么想法吗?

最佳答案

为了检验一个理论,我在一个古董文本编辑器中调出文件,我看到了

**}?**

十六进制编辑器说

20 20 20 20 2A 2A 7D 3F 2A 2A

那个 3F 不应该在那里。

关于c++ - 在简单的蛇游戏中使用未声明的标识符错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42380468/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com