v0.0.2
This commit is contained in:
1 parent
4ec6b7993c
commit
5ae0a840b0
1 file changed
+7
-5
@@ -3,6 +3,8 @@
|
||||
#include <time.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
#include "snake.h"
|
||||
|
||||
#define WIDTH 20
|
||||
#define HEIGHT 20
|
||||
|
||||
@@ -33,15 +35,15 @@ void draw() {
|
||||
clear(); // Clear the screen
|
||||
|
||||
for (int i = 0; i < WIDTH + 2; i++)
|
||||
printw("#");
|
||||
printw("-");
|
||||
printw("\n");
|
||||
|
||||
for (int i = 0; i < HEIGHT; i++) {
|
||||
for (int j = 0; j < WIDTH; j++) {
|
||||
if (j == 0)
|
||||
printw("#"); // Left wall
|
||||
printw("|"); // Left wall
|
||||
if (i == food.y && j == food.x)
|
||||
printw("F"); // Food
|
||||
printw("*"); // Food
|
||||
else {
|
||||
int isSnakePart = 0;
|
||||
for (int k = 0; k < snake.length; k++) {
|
||||
@@ -54,13 +56,13 @@ void draw() {
|
||||
printw(" ");
|
||||
}
|
||||
if (j == WIDTH - 1)
|
||||
printw("#"); // Right wall
|
||||
printw("|"); // Right wall
|
||||
}
|
||||
printw("\n");
|
||||
}
|
||||
|
||||
for (int i = 0; i < WIDTH + 2; i++)
|
||||
printw("#");
|
||||
printw("-");
|
||||
printw("\n");
|
||||
refresh(); // Refresh the screen to show changes
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user