From 793db5f00a49fa2dcad0dde90f9d49aad62961e7 Mon Sep 17 00:00:00 2001 From: Nakidai Date: Fri, 24 Nov 2023 22:14:53 +0300 Subject: [PATCH] Fix allocation bug and some other - Add *.core (core dumps) to .gitignore - Change defines of directions to enum --- .gitignore | 1 + include/player.h | 7 +------ src/player.c | 1 + 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 0fd9bb7..c0b3827 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ obj/ game +*.core diff --git a/include/player.h b/include/player.h index 33bc140..e920a90 100644 --- a/include/player.h +++ b/include/player.h @@ -4,12 +4,7 @@ #include #include "food.h" -#define UP 0 -#define RIGHT 1 -#define DOWN 2 -#define LEFT 3 - -typedef int Direction; +typedef enum { UP, RIGHT, DOWN, LEFT} Direction; typedef struct player_node_t PlayerNode; typedef struct player_t Player; diff --git a/src/player.c b/src/player.c index 3cab937..57d51b7 100644 --- a/src/player.c +++ b/src/player.c @@ -45,6 +45,7 @@ bool playerDoTick(Player *player, Food food) { bool food_collision; PlayerNode *new_head = (PlayerNode *)malloc(sizeof(PlayerNode)); + new_head->next = NULL; int head_x = player->head->x; int head_y = player->head->y;