其他分享
首页 > 其他分享> > 贪吃蛇

贪吃蛇

作者:互联网

// ChangePartitionNumber.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <stdio.h>
#include <tchar.h>
#include<stdlib.h>		//即standard library标志库头文件,里面定义了一些宏和通用工具函数
#include<conio.h>		//接收键盘输入输出
#include<time.h>			//用于获得随机数
#include <afxwin.h>		//MFC
#include <windows.h>
#include <Locale.h>


POINT meat;//蛇爱吃的肉
wchar_t *str = _T("头学习计算机技术\0");

int nextChar = 1;

int width = 66;
int height = 38;

POINT preHead;

enum DIRECTION{
	UP,
	DOWN,
	LEFT,
	RIGHT
};

typedef struct Snake{
	wchar_t ch;
	DIRECTION dir;
	POINT point;
	Snake * next;
}S;

void drawWall();
void printfSnake(S s);
void followHead(S * s);
BOOL isDoublication(S s);


void gotoxy(POINT head)
{
	COORD c;
	c.X = head.x;
	c.Y = head.y;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}

void ControlCursorPosition()
{
	drawWall();

	int second;

	second = GetTickCount();
	meat.x = second % width;
	meat.y = second % height;

	//判断奇偶数,因为奇数坐标,蛇吃不到实物
	if (meat.x & 1)
	{
		meat.x++;
	}
	if (meat.y & 1)
	{
		meat.y++;
	}

	S s;//

标签:meat,point,tailBody,next,tail,贪吃蛇,dir
来源: https://www.cnblogs.com/wangxingzhou/p/10493369.html