c语言"贪吃蛇"游戏源码

 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include "conf.h"
  
 typedef struct node
 {
  
 int x,y;
  
 struct node *next;
 }Node;
  
 typedef struct
 {
  
 Node *head,*tail;
  
 int length;
 }Snake;
 typedef struct

{
  
 int left,top,right,bottom;
 }Frame;
  
 typedef enum

//四个方向
 {
  
 up,down,left,right
 }Direction;
  
 typedef enum
 {
  
 false,true
 }bool;//*/
  
 void InitGraphMode();

//初始化图形驱动
 void CloseGraphMode();

void Foot(int,int);

void Head(int,int);
 void CreateFrame();

//完成整个游戏框架的绘制
  
void CreateSnake();
  //创建一条两个节点的蛇,蛇的每一节是队列中的一个节点
 bool PlayGame();

//游戏的主体函数,
 int Hit(int,int);
   //判断是否越界,或者撞到自身,两个参数分别是新的头接点的x,y坐标
 bool GameOver();

//绘制游戏结束时弹出的对话框

void Enqueue(Node);

//入队函数
 Node Dequeue();

//出队函数
 void ClearKeyBuf();
  //清除键盘缓冲,此函数可以消除不停的按无效键的影响
  
 Snake snake;
 Frame frame;
 void main()
 {
  
 InitGraphMode();
  
 do
  
 {
  

  http://www.huihui.cn/share/32266146

  http://www.huihui.cn/share/32266654

  http://www.huihui.cn/share/32267218

  http://www.huihui.cn/share/32267650

  http://www.huihui.cn/share/32268068

  http://www.huihui.cn/share/32268516

  http://www.huihui.cn/share/32269098

  http://www.huihui.cn/share/32269602

  http://www.huihui.cn/share/32270186

  http://www.huihui.cn/share/32270842

  http://www.huihui.cn/share/32271650

  http://www.huihui.cn/share/32272436

  http://www.huihui.cn/share/32275454

  http://www.huihui.cn/share/32285302

  http://www.huihui.cn/share/32285774

  http://www.huihui.cn/share/32286216

  http://www.huihui.cn/share/32286682

  http://www.huihui.cn/share/32287148

  http://www.huihui.cn/share/32287744

  http://www.huihui.cn/share/32288154

  http://www.huihui.cn/share/32288618

  http://www.huihui.cn/share/32289104

  http://www.huihui.cn/share/32289658

  http://www.huihui.cn/share/32290984

  http://www.huihui.cn/share/32291466

  http://www.huihui.cn/share/32293404

  http://www.huihui.cn/share/32293886

  http://www.huihui.cn/share/32294546

  http://www.huihui.cn/share/32295008

  http://www.huihui.cn/share/32295378

  http://www.huihui.cn/share/32295854

  http://www.huihui.cn/share/32296304

  http://www.huihui.cn/share/32296702

  http://www.huihui.cn/share/32297286

  http://www.huihui.cn/share/32297794

  http://www.huihui.cn/share/32298330

  http://www.huihui.cn/share/32298850

  http://www.huihui.cn/share/32299456

  http://www.huihui.cn/share/32299908

  http://www.huihui.cn/share/32300278

  http://www.huihui.cn/share/32302006

  http://www.huihui.cn/share/32302466

  http://www.huihui.cn/share/32304464

  http://www.huihui.cn/share/32305386

  http://www.huihui.cn/share/32306214

  http://www.huihui.cn/share/32306692

  http://www.huihui.cn/share/32307766

  http://www.huihui.cn/share/32308194

  http://www.huihui.cn/share/32309094

  http://www.huihui.cn/share/32309574

  http://www.huihui.cn/share/32310530

  http://www.huihui.cn/share/32310918

  http://www.huihui.cn/share/32315730

  http://www.huihui.cn/share/32316042

  http://www.huihui.cn/share/32316428

  http://www.huihui.cn/share/32317308

  http://www.huihui.cn/share/32317824

  http://www.huihui.cn/share/32318448

  http://www.huihui.cn/share/32319058

  http://www.huihui.cn/share/32322508

  http://www.huihui.cn/share/32323000

  http://www.huihui.cn/share/32323446

  http://www.huihui.cn/share/32323954

  http://www.huihui.cn/share/32324312

  http://www.huihui.cn/share/32327336

  http://www.huihui.cn/share/32332016

  http://www.huihui.cn/share/32332374

  http://www.huihui.cn/share/32332732

  http://www.huihui.cn/share/32333272

  http://www.huihui.cn/share/32333660

  http://www.huihui.cn/share/32333974

  http://www.huihui.cn/share/32337772

  http://www.huihui.cn/share/32338154

  http://www.huihui.cn/share/32338514

  http://www.huihui.cn/share/32338938

  http://www.huihui.cn/share/32345002

  http://www.huihui.cn/share/32345296

  http://www.huihui.cn/share/32346354

  http://www.huihui.cn/share/32346632

  http://www.huihui.cn/share/32346892

  http://www.huihui.cn/share/32347328

  http://www.huihui.cn/share/32347684

  http://www.huihui.cn/share/32348048

  http://www.huihui.cn/share/32348554

  http://www.huihui.cn/share/32350474

  http://www.huihui.cn/share/32350756

  http://www.huihui.cn/share/32351022

  http://www.huihui.cn/share/32351288

  http://www.huihui.cn/share/32351846

  http://www.huihui.cn/share/32352260

  http://www.huihui.cn/share/32356536

  http://www.huihui.cn/share/32357130

  http://www.huihui.cn/share/32357522

  http://www.huihui.cn/share/32359228

  http://www.huihui.cn/share/32359456

  http://www.huihui.cn/share/32360372

  http://www.huihui.cn/share/32360696

  http://www.huihui.cn/share/32360998

  http://www.huihui.cn/share/32361404

  http://www.huihui.cn/share/32361794

  http://www.huihui.cn/share/32362114

  http://www.huihui.cn/share/32362518

  http://www.huihui.cn/share/32362872

  武汉医院网络营销,武汉国技网络有限公司联系人:张经理,联系电话:18580735168,联系QQ:895589539,武汉医院网络营销,武汉国技网络有限公司主要从事网站建设、seo优化、竞价托管、整合营销等业务!武汉国技网络有限公司致力于企业网络营销方向中成功方向把握的方法研究,为中大型企业打造一套完善的网络营销体系及解决方案,并为成长中企业的创新提供不同层面的网络营销服务,致力于提高中国企业网络营销应用水平及互联网环境中企业综合竞争力。

  武汉医院网站建设,武汉国技网络有限公司联系人:张经理,联系电话:18580735168,联系QQ:895589539,武汉医院网站建设,武汉国技网络有限公司主要从事网站建设、seo优化、竞价托管、整合营销等业务!武汉国技网络有限公司致力于企业网络营销方向中成功方向把握的方法研究,为中大型企业打造一套完善的网络营销体系及解决方案,并为成长中企业的创新提供不同层面的网络营销服务,致力于提高中国企业网络营销应用水平及互联网环境中企业综合竞争力。

  http://www.huihui.cn/share/32365314

  http://www.huihui.cn/share/32365698

  http://www.huihui.cn/share/32366016

  http://www.huihui.cn/share/32366386

  http://www.huihui.cn/share/32366660

  http://www.huihui.cn/share/32367070

  http://www.huihui.cn/share/32367308

  http://www.huihui.cn/share/32367582

  http://www.huihui.cn/share/32367902

  http://www.huihui.cn/share/32368474

  http://www.huihui.cn/share/32368812

  http://www.huihui.cn/share/32369238

  http://www.huihui.cn/share/32369584

  http://www.huihui.cn/share/32370146

  http://www.huihui.cn/share/32370762

  http://www.huihui.cn/share/32371030

  http://www.huihui.cn/share/32371358

  http://www.huihui.cn/share/32371588

  http://www.huihui.cn/share/32371914

  http://www.huihui.cn/share/32372194

  http://www.huihui.cn/share/32372614

  http://www.huihui.cn/share/32378628

  http://www.huihui.cn/share/32379974

  http://www.huihui.cn/share/32380390

  http://www.huihui.cn/share/32385820

  http://www.huihui.cn/share/32386452

  http://www.huihui.cn/share/32386706

  http://www.huihui.cn/share/32387050

  http://www.huihui.cn/share/32387550

  http://www.huihui.cn/share/32397408

  http://www.huihui.cn/share/32398220

  http://www.huihui.cn/share/32398962

  http://www.huihui.cn/share/32399486

  http://www.huihui.cn/share/32399930

  http://www.huihui.cn/share/32400554

  http://www.huihui.cn/share/32400974

  http://www.huihui.cn/share/32401498

  http://www.huihui.cn/share/32401920

  http://www.huihui.cn/share/32402658

  http://www.huihui.cn/share/32403048

  http://www.huihui.cn/share/32403482

  http://www.huihui.cn/share/32410368

  http://www.huihui.cn/share/32410848

  http://www.huihui.cn/share/32411754

  http://www.huihui.cn/share/32412154

  http://www.huihui.cn/share/32412544

  http://www.huihui.cn/share/32412836

  http://www.huihui.cn/share/32413128

  http://www.huihui.cn/share/32413462

  http://www.huihui.cn/share/32413754

  http://www.huihui.cn/share/32414130

  http://www.huihui.cn/share/32414516

  http://www.huihui.cn/share/32414858

  http://www.huihui.cn/share/32415194

  http://blog.tianya.cn/blogger/post_read.asp?BlogID=4943045&PostID=56230818

  http://blog.tianya.cn/blogger/post_read.asp?BlogID=4943045&PostID=56230789

  http://blog.tianya.cn/blogger/post_read.asp?BlogID=4943045&PostID=56230561

  http://www.xiachufang.com/cook/101296989/

  http://www.xiachufang.com/cook/101296956/

  http://blog.tianya.cn/blogger/post_read.asp?BlogID=4943045&PostID=56230529

  http://zhidao.baidu.com/question/1382203899901142940.html

CreateFrame(); }while(PlayGame()); CloseGraphMode(); } void InitGraphMode() { int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,"../bgi/"); cleardevice(); } void CloseGraphMode() {  
 cleardevice();
  
 closegraph();
 }
 void CreateFrame()
 {
  
 setbkcolor(CYAN);

//下面的四行代码用于计算主框架的左上角和右下角的坐标
  
 frame.left=(getmaxx()+1-BlockWidth*RowOfFrame)/2;
  
  frame.top=(getmaxy()+1-BlockHeight*ColumnOfFrame)/2;
  
 frame.right=frame.left+BlockWidth*RowOfFrame;
  
 frame.bottom=frame.top+BlockHeight*ColumnOfFrame;
  
 Head(frame.left+100,frame.top-20);
  
 setfillstyle(SOLID_FILL,LIGHTGRAY);
  
 bar(frame.left,frame.top,frame.right,frame.bottom);
  
 setlinestyle(SOLID_LINE,1,1);
  
 setcolor(DARKGRAY);
  
 line(frame.left,frame.top,frame.right,frame.top);
  
 line(frame.left,frame.top,frame.left,frame.bottom);
  
 setlinestyle(SOLID_LINE,1,1);
  
 setcolor(WHITE);
  
 line(frame.left,frame.bottom,frame.right,frame.bottom);
  
 line(frame.right,frame.top,frame.right,frame.bottom);
  
 setlinestyle(DOTTED_LINE,1,1);
  
 setcolor(BLUE);
  
 for(int row=1;rowx=frame.left+BlockWidth;
  
 node1->y=frame.top;
  
 node1->next=NULL;
  
 snake.tail=node1;
  
 node2->x=frame.left;
  
 node2->y=frame.top;
  
 node2->next=snake.tail;
  
 snake.head=node2;
  
 snake.length=2;
   
 

你可能感兴趣的:(c语言数数小游戏)