Browse Source

refactoring: draw_snake

remotes/origin/David
David Moeller 11 months ago
parent
commit
101a65d293
  1. 8
      src/main/c/Snake/snake_start.c

8
src/main/c/Snake/snake_start.c

@ -150,7 +150,13 @@ void draw_snake(Snake *snake, unsigned char fruit){
printf("|"); printf("|");
for(int j = 1; j <= WIDTH; j++){ for(int j = 1; j <= WIDTH; j++){
int index = part_of_snake(snake, i * 16 + j); int index = part_of_snake(snake, i * 16 + j);
if(index == 0){printf("0");}
if(index == 0){
switch(snake->direction){
case -16: printf("A");break;
case -1: printf("<");break;
case 1: printf(">");break;
case 16: printf("V");break;
default: break;}}
else if(index > 0){printf("O");} else if(index > 0){printf("O");}
else if(i * 16 + j == fruit){printf("X");} else if(i * 16 + j == fruit){printf("X");}
else{printf(" ");} else{printf(" ");}

Loading…
Cancel
Save