|
|
@ -17,6 +17,7 @@ void main_menu(); |
|
|
|
void game(); |
|
|
|
Snake initialize_game(); |
|
|
|
void draw(Snake *snake); |
|
|
|
int part_of_snake(Snake *snake, unsigned char tile); |
|
|
|
|
|
|
|
|
|
|
|
void snake_start(){ |
|
|
@ -83,24 +84,24 @@ void draw(Snake *snake){ |
|
|
|
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(" "); |
|
|
|
} |
|
|
|
} |
|
|
|
int index = part_of_snake(snake, i * 16 + j); |
|
|
|
if(index == 0){printf("0");} |
|
|
|
else if(index > 0){printf("O");} |
|
|
|
else{printf(" ");} |
|
|
|
} |
|
|
|
printf("|\n"); |
|
|
|
} |
|
|
|
printf("+"); |
|
|
|
for(int i = 0; i < WIDTH; i++){printf("-");} |
|
|
|
printf("+\n"); |
|
|
|
} |
|
|
|
|
|
|
|
//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++){ |
|
|
|
if(snake->segments[i] == tile){ |
|
|
|
return i; |
|
|
|
} |
|
|
|
} |
|
|
|
return -1; |
|
|
|
} |