diff options
| author | Preston Pan <preston@nullring.xyz> | 2023-02-06 01:36:51 -0800 |
|---|---|---|
| committer | Preston Pan <preston@nullring.xyz> | 2023-02-06 01:36:51 -0800 |
| commit | c722aaf5f9dbed456d10d48f48f2bb8732434dbd (patch) | |
| tree | 67ce5086ae83d0c93dda362a18cb8fb78d0b9b3d /snake.c | |
| parent | ca31b6ebf0e1e2f177fe5b4953f0a6929170a6cc (diff) | |
| parent | df22092a336543c0f6d2c605e0aa96df7d2ccae2 (diff) | |
Merge branch 'master' of ssh://aberrantflux.xyz:/home/git/repo/public/snake3
merge
Diffstat (limited to 'snake.c')
| -rw-r--r-- | snake.c | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -171,7 +171,6 @@ void draw_board() { printf("\033[0;0H"); //iterate through and write the board for(int r = 0; r < boardSize; r++) { - char* line = calloc(boardSize * 2, sizeof(char)); for(int c = 0; c < boardSize; c++) { //determine the contents of the board position int type = 0; @@ -190,27 +189,21 @@ void draw_board() { //append the appropriate value if(type == 0) { //empty square - line[c * 2] = '`'; - line[(c * 2) + 1] = ' '; + printf("` "); } else if(type == 1) { //snake head - line[c * 2] = '@'; - line[(c * 2) + 1] = ' '; + printf("%s@ %s", GRN, COLOR_RESET); } else if(type == 2) { //snake body - line[c * 2] = '*'; - line[(c * 2) + 1] = ' '; + printf("%s* %s", GRN, COLOR_RESET); } else if(type == 3) { - //snake body - line[c * 2] = 'F'; - line[(c * 2) + 1] = ' '; + //food + printf("%sF %s", MAG, COLOR_RESET); } } - printf(line); printf("\n"); - free(line); } } |
