#define N 200
#include<graphics.h>
#include<stdlib.h>
#include<dos.h>
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define Esc 0x011b
int i,key;
int score=0;
int gamespeed=50000;
struct Food
{int x;
int y;
int yes;
}food;
struct Snake
{int x[N];
int y[N];
int node;
int direction;
int life;
}snake;
void Init();
void Close();
void DrawK();
void GamePlay();
void GameOver();
void PrScore();
void main()
{ Init();
DrawK();
GamePlay();
Close();
}
void Init()
{int gd=DETECT,gm;
initgraph(&gd,&gm,"F:\\tuoboc2");/*此处为turboc的路径,读者可以根据自己的电脑而改*/
cleardevice();
}
void DrawK()
{setbkcolor(LIGHTGREEN);
setcolor(11);
setlinestyle(SOLID_LINE,0,THICK_WIDTH);
for(i=50;i<=600;i+=10)
{rectangle(i,40,i+10,49);
rectangle(i,451,i+10,460);
}
for(i=40;i<=450;i+=10)
{rectangle(50,i,59,i+10);
rectangle(601,i,610,i+10);
}
}
void GamePlay()
{randomize();
food.yes=1;
snake.life=0;
snake.direction=1;