#include #include #include #include #include #define framerate 8.0 #define screen_width 640 #define screen_height 480 #define BLOCK_LEN 10 #define GRID_HEIGHT 16 #define GRID_WIDTH 16 #define GRID_BORDER_WIDTH 10 _Bool is_snake(int x, int y, int* snake_x, int* snake_y,int snake_length){ for(int i=0; i=GRID_WIDTH) next_pos_x=0; if(next_pos_x<0) next_pos_x=GRID_WIDTH-1; if(next_pos_y>=GRID_HEIGHT) next_pos_y=0; if(next_pos_y<0) next_pos_y=GRID_HEIGHT-1; if(next_pos_x==apple_x && next_pos_y==apple_y){ memmove(pos_x+head_i+2,pos_x+head_i+1,sizeof(int)*(length-head_i-1)); memmove(pos_y+head_i+2,pos_y+head_i+1,sizeof(int)*(length-head_i-1)); length++; create_apple(&apple_x,&apple_y,pos_x,pos_y,length); } head_i++; if(head_i>=length) head_i=0; draw_box(pos_x[head_i],pos_y[head_i],al_map_rgb(0,0,0)); pos_x[head_i]=next_pos_x; pos_y[head_i]=next_pos_y; draw_box(apple_x,apple_y,al_map_rgb(255,0,0)); //for(int i =0;i