diff --git a/src/main/c/Snake/snake_start.c b/src/main/c/Snake/snake_start.c index 0584deb..a56e34c 100644 --- a/src/main/c/Snake/snake_start.c +++ b/src/main/c/Snake/snake_start.c @@ -150,7 +150,7 @@ void draw(Snake *snake, unsigned char fruit){ //returns index of segments which is identical to tile; -1 if not found int part_of_snake(Snake *snake, unsigned char tile){ - for(int i = 0; i < snake->length; i++){ + for(int i = snake->length - 1; i >= 0; i--){ if(snake->segments[i] == tile){ return i; } @@ -160,11 +160,8 @@ int part_of_snake(Snake *snake, unsigned char tile){ bool check_if_dead(Snake *snake){ //Self - for(int i = 0; i < snake->length; i++){ - int part = part_of_snake(snake, snake->segments[i]); - if(part != -1 && part != i){ - return true; - } + if(part_of_snake(snake, snake->segments[0]) > 0){ + return true; } //Wall