贪吃蛇游戏c语言源代码_第1页
贪吃蛇游戏c语言源代码_第2页
贪吃蛇游戏c语言源代码_第3页
贪吃蛇游戏c语言源代码_第4页
贪吃蛇游戏c语言源代码_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

c txt include include include include include define Enter 7181 define ESC 283 define UP 18432 define DOWN 20480 define LEFT 19200 define RIGHT 19712 ifdef cplusplus define CPPARGS else define CPPARGS endif void interrupt oldhandler CPPARGS void interrupt newhandler CPPARGS void SetTimer void interrupt IntProc CPPARGS void KillTimer void void Initgra void void TheFirstBlock void void DrawMap void void Initsnake void void Initfood void void Snake Headmv void void Flag int int int int void GameOver void void Snake Bodymv void void Snake Bodyadd void void PrntScore void void Timer void void Win void void TheSecondBlock void void Food void void Dsnkorfd int int int void Delay int struct Snake int x int y int color Snk 12 struct Food int x int y int color Fd int flag1 1 flag2 0 flag3 0 flag4 0 flag5 0 flag6 0 checkx checky num key 0 Times Score Hscore Snkspeed TimerCounter TureorFalse char Sco 2 Time 6 void main Initgra SetTimer newhandler TheFirstBlock while 1 DrawMap Snake Headmv GameOver Snake Bodymv Snake Bodyadd PrntScore Timer Win if key ESC break if key Enter cleardevice TheFirstBlock TheSecondBlock Food Delay Snkspeed closegraph KillTimer void interrupt newhandler CPPARGS TimerCounter oldhandler void SetTimer void interrupt IntProc CPPARGS oldhandler getvect 0 x1c disable setvect 0 x1c IntProc enable void KillTimer disable setvect 0 x1c oldhandler enable void Initgra int gd DETECT gm initgraph void TheFirstBlock setcolor 11 settextstyle 0 0 4 outtextxy 100 220 The First Block loop key bioskey 0 if key Enter cleardevice Initsnake Initfood Score 0 Hscore 1 Snkspeed 10 num 2 Times 0 key 0 TureorFalse 1 TimerCounter 0 Time 0 0 Time 1 0 Time 2 Time 3 1 Time 4 0 Time 5 0 else if key ESC cleardevice else goto loop void DrawMap line 10 10 470 10 line 470 10 470 470 line 470 470 10 470 line 10 470 10 10 line 480 20 620 20 line 620 20 620 460 line 620 460 480 460 line 480 460 480 20 void Initsnake randomize num 2 Snk 0 x random 440 Snk 0 x Snk 0 x Snk 0 x 20 50 Snk 0 y random 440 Snk 0 y Snk 0 y Snk 0 y 20 50 Snk 0 color 4 Snk 1 x Snk 0 x Snk 1 y Snk 0 y 20 Snk 1 color 4 void Initfood randomize Fd x random 440 Fd x Fd x Fd x 20 30 Fd y random 440 Fd y Fd y Fd y 20 30 Fd color random 14 1 void Snake Headmv if bioskey 1 key bioskey 0 switch key case UP Flag 1 0 0 0 break case DOWN Flag 0 1 0 0 break case LEFT Flag 0 0 1 0 break case RIGHT Flag 0 0 0 1 break default break if flag1 checkx Snk 0 x checky Snk 0 y Dsnkorfd Snk 0 x Snk 0 y 0 Snk 0 y 20 Dsnkorfd Snk 0 x Snk 0 y Snk 0 color if flag2 checkx Snk 0 x checky Snk 0 y Dsnkorfd Snk 0 x Snk 0 y 0 Snk 0 y 20 Dsnkorfd Snk 0 x Snk 0 y Snk 0 color if flag3 checkx Snk 0 x checky Snk 0 y Dsnkorfd Snk 0 x Snk 0 y 0 Snk 0 x 20 Dsnkorfd Snk 0 x Snk 0 y Snk 0 color if flag4 checkx Snk 0 x checky Snk 0 y Dsnkorfd Snk 0 x Snk 0 y 0 Snk 0 x 20 Dsnkorfd Snk 0 x Snk 0 y Snk 0 color void Flag int a int b int c int d flag1 a flag2 b flag3 c flag4 d void GameOver int i if Snk 0 x460 Snk 0 y460 cleardevice setcolor 11 settextstyle 0 0 4 outtextxy 160 220 Game Over loop1 key bioskey 0 if key Enter cleardevice TheFirstBlock else if key ESC cleardevice else goto loop1 for i 3 i num i if Snk 0 x Snk i x setcolor 11 settextstyle 0 0 4 outtextxy 160 220 Game Over loop2 key bioskey 0 if key Enter cleardevice TheFirstBlock else if key ESC cleardevice else goto loop2 void Snake Bodymv int i s t for i 1 iSnk num 2 x num Snk num 1 x Snk num 2 x 20 Snk num 1 y Snk num 2 y Snk num 1 color Fd color else if Snk num 1 xSnk num 2 y num Snk num 1 x Snk num 2 x Snk num 1 y Snk num 2 y 20 Snk num 1 color Fd color else if Snk num 1 y18 Time 4 char Time 4 1 if Time 4 0 Time 4 9 Time 3 char Time 3 1 if Time 3 0 Time 3 5 Time 1 char Time 1 1 if TureorFalse setcolor 11 settextstyle 0 0 3 outtextxy 490 240 TIMER setcolor 2 setfillstyle 1 0 rectangle 490 280 610 320 floodfill 530 300 2 setcolor 11 settextstyle 0 0 3 outtextxy 495 290 Time TureorFalse 0 if Time 1 0 settextstyle 0 0 4 outtextxy 160 220 Game Over loop key bioskey 0 if key Enter cleardevice TheFirstBlock else if key ESC cleardevice else goto loop TimerCounter 0 TureorFalse 1 void Win if Score 3 Times if Times 2 cleardevice setcolor 11 settextstyle 0 0 4 outtextxy 160 220 You Win loop key bioskey 0 if key Enter cleardevice TheFirstBlock key 0 else if key ESC cleardevice else goto loop void TheSecondBlock if Score 3 cleardevice setcolor 11 settextstyle 0 0 4 outtextxy 100 220 The Second Block loop key bioskey 0 if key Enter cleardevice Initsnake Initfood Score 0

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论