The terminal windows keeps flickering when i run the snake game, below i will share my draw function I'm not sure if its a windows issue because of 'cls' or i made a mistake somewhere
void Draw (){
system("cls");
for (int i=0; i<width+2; i++){
cout<<"#";
}cout<< endl;
for (int i=0; i < height; i++ ){
for (int j =0; j <width; j++){
if (j == 0)
cout << "#";
if ( i ==y && j ==x)
cout << "O";
else if ( i == fruitY && j == fruitX)
cout << "F";
else{
bool print = false;
for (int k =0; k <nTail; k++){
if (tailx[k] == j && taily[k] == i)
{
cout<<"-";
print = true;
}
}
if (!print)
cout << " ";
}
if(j == width -1)
cout << "#";
}
cout << endl;
}
for (int i=0; i<width+2; i++){
cout<<"#";
}cout<< endl;
cout << "Score: "<< score <<endl;
cout << "To Exit press 'x'"<<endl;
}
i was wondering if there is a way to fix it