工程量快速计算方法
*程序名:贪吃蛇
/*===========================================================
*调用库:
*----------------------
*图形库graphics.h,随机库stdlib.h
*===========================================================*/
#include
#include
/*===========================================================
*宏定义:
*----------------------
*上、下、左、右、退出(ESC),暂停(PAUSE),确定(ENTER)
*alive---蛇活着,dead---蛇死亡
*no---食物不存在,yes---食物存在
*N---蛇最大长度,达到200时游戏完成
*===========================================================*/
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define ESC 0x011b
#define SPACE 0x3920
#define ENTER 0x1c0d
#define alive 1
#define dead 0
#define yes 1
#define no 0
#define N 200
/*===========================================================
*自定义函数以及全局变量声明
*---------------------------
*Score---统计吃的食物个数;Speed_degree:控制蛇速度变量
*===========================================================*/
void make_full_screen();
void start_screen();
void menu();
void wall_note();
void play_game();
void score();
void game_over();
void close_full_screen();
void victory();
void forum();
void leave_or_again();
void victory();
int Score,Speed_degree;
/*===========================================================
*自定义函数:make_full_screen()
*---------------------------------
*初始化图形界面
*===========================================================*/
void make_full_screen()
{
int driver=DETECT,mode;
registerbgidriver(EGAVGA_driver);
initgraph(&driver,&mode,"");
cleardevice();
}
/*===========================================================
*自定义函数:start_screen()
*------------------------------
*贪吃蛇游戏的欢迎界面
*===========================================================*/
void start_screen()
{
int i,p,color=9;
settextstyle(0,0,2);
setcolor(GREEN);
outtextxy(150,400,"Press any key to loading...");
setcolor(YELLOW);
outtextxy(200,450,"Deviser:caolvchong");
forum();
while(bioskey(1)==0) /*当没有按键时显示snake*/
{
settextstyle(0,0,6);
for(i=9;i<15;i++)
{
color++;
if(color>=14) color=9;
setcolor(color);
outtextxy(200,200,"SNAKE");
for(p=1;p<3;p++)
delay(50000);
}
}
bioskey(0);/*返回键盘值,不然按下的扫描码将被后面检测按键函数接收*/
cleardevice();/*清屏*/
}
/*===========================================================
*自定义函数:menu()
*------------------------------
*贪吃蛇游戏的菜单界面
*===========================================================*/
void menu()
{
int j=100,k=j,n,key,tag=1;
char *char_up=NULL,*char_down=NULL;
/*----