C语言贪吃蛇再进化!
摘要:嗯,这是终结版,虽然还有一些地方不完善,但我感觉也没必要完善。只是纠结于AI的自动寻物还是有问题,桑心。GCC编译命令gcc -Wall -D_REENTRANT -o "%e" "%f" -lncurses -lpthreadsnakeGame.c 1 #include "snakeAI.c" 2 #define CTRL_TIMES 1000 // AI每秒显示的最大步数 3 #define WINDOW_W 40 4 #define WINDOW_H 10 5 int threadtype=-1,threadbool=0; 6
阅读全文
原创:C语言贪吃蛇代码
摘要:源代码使用GCC编译器编译并运行于Linux,想在windows下运行需要修改少许字符输出语句。在自动控制snake上下了很大功夫,但是对防止进入自身封闭上做的很不好,而且没有使用另一线程实现玩家控制方向。为了方便编写,分为“snakeGame”、“sankeAI”、“sankeHead.h"三个文件。“sankeHead.h" 1 #include <unistd.h> 2 #include <stdlib.h> 3 #include <curses.h> 4 #include <time.h> 5 typedef enum
阅读全文