资源简介
通过学习终端下贪吃蛇游戏,可以理解linux下curses图形库的调用,以及linux如何通过signal信号产生中断,并且执行相应的函数。
代码片段和文件信息
/* Filename: snake.c version:1.0 date: 2011/08/21
* Author: Dream Fly blog: blog.csdn.net/jjzhoujun2010
* Usage: ‘f‘ means speed up ‘s‘ means speed down ‘q‘ means quit;
* Navigation key controls the snake moving.
* Compile: gcc snake.c -lcurses -o snake
*/
#include
#include
#include
#include
#include
#include“snake.h“
struct position food; /* food position */
Snake_Node *head *tail; /* double linked list‘s head and tail */
int x_dir = 1 y_dir = 0; /* init dirction of the snake moving */
int ttm = 5 ttg = 5; /* two timers defined to control speed */
void main(void)
{
Init_Disp(); /* init and display the interface */
Food_Disp(); /* display food */
DLL_Snake_Create(); /* create double linked list and display snake
- 上一篇:定时打铃器专业课程设计报告
- 下一篇:2011年高教杯数学建模竞赛D题获奖论文
评论
共有 条评论