diff --git a/src/main/c/Snake/snake_start.c b/src/main/c/Snake/snake_start.c index 4e21045..57d332f 100644 --- a/src/main/c/Snake/snake_start.c +++ b/src/main/c/Snake/snake_start.c @@ -9,7 +9,7 @@ typedef struct{ signed char direction[2]; char length; - char segments[AREA]; + unsigned char segments[AREA]; }Snake; @@ -58,9 +58,11 @@ void game(){ bool running = true; while (running) { + system("clear"); draw(&snake); + running = false; } - + getchar(); } Snake initialize_game(){ @@ -78,12 +80,27 @@ void draw(Snake *snake){ printf("+"); for(int i = 0; i < WIDTH; i++){printf("-");} printf("+\n"); - for(int i = 0; i < HEIGHT; i++){ - for(int j = 0; j < WIDTH; j++){ - + for(int i = 1; i <= HEIGHT; i++){ + printf("|"); + for(int j = 1; j <= WIDTH; j++){ + //printf("%d:", i * 16 + j); + for(int pos = 0; pos < snake->length; pos++){ + //printf(" %d", snake->segments[pos]); + if(i * 16 + j == snake->segments[pos]){ + if(pos == 0){ + printf("0"); + }else{ + printf("O"); + } + break; + }else if(pos == snake->length - 1){ + printf(" "); + } + } } + printf("|\n"); } printf("+"); - for(int i = 0; i < WIDTH; i++){printf("_");} - printf("\n"); + for(int i = 0; i < WIDTH; i++){printf("-");} + printf("+\n"); } \ No newline at end of file