在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; /