Делаю змейку на c++ не получается ввод с русской раскладки
void Input()
{
if (kbhit())
{
char c=_getch();
if (c=='w' || c=='ц') GolP=Pos::UP; else
if (c=='s' || c=='ы') GolP=Pos::DOWN; else
if (c=='d' || c=='в') GolP=Pos::RIGHT; else
if (c=='a' || c=='ф') GolP=Pos::LEFT;
}
}
P.S. Вот весь код :
#include <bits/stdc++.h>
#include <time.h>
#include <windows.h>
#include <conio.h>
using namespace std;
bool GameEnd = false;
enum Pos {DOWN,RIGHT,LEFT,UP};
int score=0;
int XvostX[100],XvostY[100],XvostT=0;
const int rows=20;
const int columns=20;
int GolX=rows/2-1;
int GolY=columns/2-1;
Pos GolP=Pos::UP;
int FruitX,FruitY;
void Draw()
{
system("cls");
for (int i=0; i<rows; i++)
for (int j=0; j<columns; j++)
{
int otstup=0;
for (int k=0; k<XvostT; k++) if (XvostX[k]==i && XvostY[k]==j) {cout << 'o'; otstup++;}
if (GolX==i && GolY==j) {cout << 'O'; otstup++;}
if (GolX==i && GolY==j && GolX==FruitX && GolY==FruitY) {} else if (FruitX==i && FruitY==j) {cout << '@'; otstup++; }
if (j==0 || j==columns-1 || i==0 || i==rows-1) cout << '#';
if (j==columns-1) cout << endl; else if (i!=0 && i!=rows-1 && otstup==0) cout << " ";
}
cout << "Счет:" << score;
Sleep(200);
}
void Logic()
{
if (GolX==0 || GolX==rows-1 || GolY==0 || GolY==columns-1) {GameEnd=true; return;}
if (GolX==FruitX && GolY==FruitY)
{
XvostT++;
FruitX=rand() % rows;
FruitY=rand() % columns;
while (FruitX==0 || FruitX==rows-1 || FruitY==0 || FruitY==columns-1) {FruitX=rand() % rows; FruitY=rand() % columns;}
score++;
}
int PrX=XvostX[0];
int PrY=XvostY[0];
int Pr2X,Pr2Y;
XvostX[0]=GolX;
XvostY[0]=GolY;
for (int i=1; i<XvostT; i++)
{
Pr2X=XvostX[i];
Pr2Y=XvostY[i];
XvostX[i]=PrX;
XvostY[i]=PrY;
PrX=Pr2X;
PrY=Pr2Y;
}
if (GolP==Pos::UP) {GolX--;}
if (GolP==Pos::DOWN) {GolX++;}
if (GolP==Pos::LEFT) {GolY--;}
if (GolP==Pos::RIGHT) {GolY++;}
for (int i=0; i<XvostT; i++)
{
if (XvostX[i]==GolX && XvostY[i]==GolY) {GameEnd=true; return;}
}
}
void Input()
{
if (kbhit())
{
char c=_getch();
if (c=='w' || c=='ц') GolP=Pos::UP; else
if (c=='s' || c=='ы') GolP=Pos::DOWN; else
if (c=='d' || c=='в') GolP=Pos::RIGHT; else
if (c=='a' || c=='ф') GolP=Pos::LEFT;
}
}
int main()
{
srand(time(NULL));
setlocale(LC_ALL, "Russian");
while (FruitX==0 || FruitX==rows-1 || FruitY==0 || FruitY==columns-1) {FruitX=rand() % rows; FruitY=rand() % columns;}
while (!GameEnd)
{
Input();
Logic();
Draw();
}
system("cls");
cout << "Вы проиграли :( , ваш счёт : " << score;
_getch();
}