简单的贪吃蛇代码,可上机运行

 贪吃蛇无敌版,可穿墙,英文输入法小写字母wasd操作。

#include
#include
#include
#include
#include

#define up 'w'
#define down 's'
#define left 'a'
#define right 'd'
#define space 'q'
#define slow 'e'

void gotoxy(int x, int y);
int ClickControl();
void moveobject();
void food();
int color(int c);
void border();
void wall();
//srand((unsigned)time(0));


int j,i,k,click,length=5;
int _time=100000000;
typedef struct Snake
{
    int x;
    int y;
    struct Snake *next;
}snake;
snake s={15,15};
snake *head;
snake ss[100];

main()
{

	int c;

    ss[0]=s;
    snake temp[2];
	for(i=1;ix<=1)
	    head->x=61;
	else if(head->x>=61)
	    head->x=1;
	if(head->y<=0)
	    head->y=28;
	else if(head->y>=28)
	    head->y=0;
}

void wall()
{
	color(5);
	gotoxy(0,0);
	for(i=0;i<=61;i+=2)
	{
		printf("■");
	}
	gotoxy(0,28);
	for(i=0;i<=61;i+=2)
	{
		printf("■");
	}
	for(i=0;i<=28;i++)
	{
		gotoxy(0,i);
		printf("■");
	}
	for(i=0;i<=28;i++)
	{
		gotoxy(62,i);
		printf("■");
	}
}

运行结果如下:

简单的贪吃蛇代码,可上机运行_第1张图片

 

你可能感兴趣的:(蓝桥杯,c语言,算法)