diff options
Diffstat (limited to 'src/snake.c')
| -rw-r--r-- | src/snake.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/snake.c b/src/snake.c index 577c832..7f9a32a 100644 --- a/src/snake.c +++ b/src/snake.c @@ -176,6 +176,10 @@ int main(int argc, char **argv) { nanosleep(&time, NULL); /* read the most recent value emitted by the listener */ vector_t dir = parse_dir(*(char*)lastInput); + + if (dir.mx == -2) { + goto EXIT; + } /* if the player inputted a valid direction, use it. otherwise, use his last valid input */ if((dir.mx != 0 || dir.my != 0) && !(dir.mx == 1 && lastMoveDir.mx == -1) && !(dir.mx == -1 && lastMoveDir.mx == 1) && !(dir.my == 1 && lastMoveDir.my == -1) && !(dir.my == -1 && lastMoveDir.my == 1)) { lastMoveDir = dir; @@ -256,7 +260,9 @@ vector_t parse_dir(char cDir) { } else if(cDir == 'a' || cDir == 'h') { return init_vector(-1, 0); - } + } else if (cDir == 'q') { + return init_vector(-2, -2); + } else { return init_vector(0, 0); } |
