add_snake

This commit is contained in:
Kamil Gejdoš 2026-04-14 15:05:29 +00:00
parent e4b6ac0ddd
commit 82bb5222c8

View File

@ -1,8 +1,17 @@
#include "snake.h" #include "snake.h"
#include <stdlib.h> #include <stdlib.h>
struct snake* add_snake(struct snake* snake,int x,int y){ struct snake* add_snake(struct snake* snake,int x,int y){
return NULL;
struct snake* nova_hlava = malloc(sizeof(struct snake)); //vytvorim novu hlavu na ktoru nalinkujem staru hlavu ako telo
nova_hlava -> x = x;
nova_hlava -> y = y; //zapisem suradnice novej hlavy do novej struktury
nova_hlava -> next = snake; //dalsi segment (next) je stara hlava zo vstupu funkcie
return nova_hlava;
} }
struct snake* remove_snake(struct snake* snake){ struct snake* remove_snake(struct snake* snake){