Aktualizovat du4 /snake.c
This commit is contained in:
parent
47ac20e4b6
commit
4cefc5a5a6
27
du4 /snake.c
27
du4 /snake.c
@ -1,8 +1,21 @@
|
|||||||
#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;
|
{
|
||||||
|
if (snake == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
//pomocna smernikova premenna
|
||||||
|
struct snake* currentPtr = snake;
|
||||||
|
while (currentPtr != NULL)
|
||||||
|
{
|
||||||
|
//uloz dalsiu cast
|
||||||
|
struct snake* nextPtr = currentPtr->next;
|
||||||
|
free(currentPtr);
|
||||||
|
currentPtr = nextPtr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct snake* remove_snake(struct snake* snake){
|
struct snake* remove_snake(struct snake* snake){
|
||||||
@ -11,7 +24,15 @@ struct snake* remove_snake(struct snake* snake){
|
|||||||
|
|
||||||
void free_snake(struct snake* sn)
|
void free_snake(struct snake* sn)
|
||||||
{
|
{
|
||||||
|
//pomocna pointer premanna
|
||||||
|
struct snake* currentPtr = sn;
|
||||||
|
while (currentPtr != NULL)
|
||||||
|
{
|
||||||
|
//uloz dalsiu cast
|
||||||
|
struct snake* nextPtr = currentPtr->next;
|
||||||
|
free(currentPtr);
|
||||||
|
currentPtr = nextPtr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_snake(struct snake* snake,int x,int y){
|
int is_snake(struct snake* snake,int x,int y){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user