好玩的贪吃蛇
不多说, 上代码, 拿去玩吧 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <windows.h> 4 #include <conio.h> 5 6 #define High 30 7 #define Width 30 8 9 int direction; 10 int length_snake; 11 int x_food, y_food; 12 int x_snake, y_snake; 13 int /*score,*/ speed, speedTop; 14 int canvas[High][Width] = {0}; 15 16 void startup(); 17 void show(); 18 void updateWithoutInput(); 19 void updateWithInput(); 20 void moveSnake(); 21 void gotoxy(int x, int y) 22 { 23 HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); 24 COORD pos; 25 pos.X = x; 26 pos.Y = y; 27 SetConsoleCursorPosition(handle, pos); 28 } 29 void