funguje
This commit is contained in:
		
							parent
							
								
									d72c96d0c6
								
							
						
					
					
						commit
						9ec5ae06fe
					
				
							
								
								
									
										26
									
								
								cv9/snake.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								cv9/snake.c
									
									
									
									
									
								
							@ -1,24 +1,6 @@
 | 
				
			|||||||
#include <stdio.h>
 | 
					#include "snake.h"
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define FOOD_COUNT 5
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct snake {
 | 
					 | 
				
			||||||
    int x;
 | 
					 | 
				
			||||||
    int y;
 | 
					 | 
				
			||||||
    struct snake* next;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct state {
 | 
					 | 
				
			||||||
    struct snake* snake;
 | 
					 | 
				
			||||||
    int foodx[FOOD_COUNT];
 | 
					 | 
				
			||||||
    int foody[FOOD_COUNT];
 | 
					 | 
				
			||||||
    int sx;
 | 
					 | 
				
			||||||
    int sy;
 | 
					 | 
				
			||||||
    int width;
 | 
					 | 
				
			||||||
    int height;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct snake* add_snake(struct snake* snake, int x, int y) {
 | 
					struct snake* add_snake(struct snake* snake, int x, int y) {
 | 
				
			||||||
    struct snake* head = (struct snake*)malloc(sizeof(struct snake));
 | 
					    struct snake* head = (struct snake*)malloc(sizeof(struct snake));
 | 
				
			||||||
    if (head == NULL) {
 | 
					    if (head == NULL) {
 | 
				
			||||||
@ -57,8 +39,8 @@ void free_snake(struct snake* snake) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main() {
 | 
					int step_state(struct state* state) {
 | 
				
			||||||
    // Place your testing code here
 | 
					    // Implement step_state function here
 | 
				
			||||||
    return 0;
 | 
					    return END_CONTINUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user