forked from nakidai/csnake
1
0
Fork 0

Fix allocation bug and some other

- Add *.core (core dumps) to .gitignore
- Change defines of directions to enum
Nakidai 2023-11-24 22:14:53 +03:00
parent 1d63892d67
commit 793db5f00a
3 changed files with 3 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
obj/
game
*.core

View File

@ -4,12 +4,7 @@
#include <stdbool.h>
#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;

View File

@ -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;