Skip to content

Commit

Permalink
fix esc detection
Browse files Browse the repository at this point in the history
  • Loading branch information
itsbudyn committed Nov 4, 2021
1 parent ffad775 commit 0853739
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions snake/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define KEY_DOWN 80
#define KEY_LEFT 75
#define KEY_RIGHT 77
#define KEY_ESC 113
#define KEY_ESC 27

void Game::ShowConsoleCursor(const bool showFlag) {
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
Expand All @@ -31,7 +31,7 @@ Game::Game() {
if (_kbhit()) {

unsigned char c =_getch();
if (c==224 || c==27){
if (c==224){
switch(_getch()){
case KEY_UP:
c='w';
Expand All @@ -45,9 +45,6 @@ Game::Game() {
case KEY_RIGHT:
c='d';
break;
case KEY_ESC:
c='q';
break;
}
}
switch (c) {
Expand All @@ -63,6 +60,7 @@ Game::Game() {
case 'd':
this->lv.snake.changeDir('e');
break;
case KEY_ESC:
case 'q':
this->lv.snake.crashSnake();
break;
Expand Down

0 comments on commit 0853739

Please sign in to comment.