From bab6423fb97e16d307a851fef323b5755755ddbe Mon Sep 17 00:00:00 2001 From: Michal Utlak Date: Wed, 10 Apr 2024 20:57:12 +0200 Subject: [PATCH] is snake --- cv9/snake.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cv9/snake.c b/cv9/snake.c index 985cc10..a0cf258 100644 --- a/cv9/snake.c +++ b/cv9/snake.c @@ -35,7 +35,21 @@ void free_snake(struct snake* sn){ } int is_snake(struct snake* snake,int x,int y){ - return 0; + if(snake == NULL){ + return NULL; + } + + struct snake* pozicia = snake; + + while(pozicia != NULL){ + if(pozicia->x == x && pozicia->y == y){ + return 1; + } + else{ + return 0; + } + } + } int step_state(struct state* st){