在linux下用c语言写贪吃蛇游戏

在linux系统下的非图形界面(在输入命令的SHELL界面按ctrl+alt+F2,然后输入账号密码),用root用户进行编译。(只用系统自带数据库即可实现)


#include<stdio.h>
#include<stdlib.h>
#include<sys/mman.h>
#include<linux/fb.h>
#include<fcntl.h>
#include<linux/kernel.h>
#include<linux/random.h>
#include<sys/select.h>
#include<termios.h>

#define H 20	//界面高度
#define L 20	//界面长度
#define N 10	//隐藏像素点个数。大部分电脑为0;一部分为10;还有一些是40多。只能试....
#define	 RGB888(r,g,b)	 ((r & 0xff) <<16 | (g & 0xff) << 8 | (b & 0xff))	//颜色定义
#define UP    0x415b1b
#define DOWN  0x425b1b
#define LEFT  0x445b1b
#define RIGHT 0x435b1b
#define ESC   0x1b

struct snake{
	int x;	//x,yx为蛇的坐标
	int y;
	int now;	//0,1,2,3分别表示当前向上,下,左,右移动。
	struct snake* next;
};
struct food{
  	//食物
	int x;
	int y;
};
static struct food* food = NULL;
static struct snake* head = NULL;
const int addx[4] = {-1,1,0,0};
const int addy[4] = {0,0,-1,1};
int t = 500000;		/
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值