c语言贪吃蛇文档,C语言实现贪吃蛇游戏

工程量快速计算方法

*程序名:贪吃蛇

/*===========================================================

*调用库:

*----------------------

*图形库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;

/*----

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值