夜光序言:
有时候会怀疑,支离破碎的我们如何拼凑后来的结局的完整,可是我们,其实是被保护得太完整。
正文:今日的课题
怎么做呢~
首先,我们需要程序编写一个地图
map地图
记得开发调度系统的时候,就提及过,opentcs的地图
或者说在研究路径规划的时候
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 测试1
{ //夜光
//这个是地图类,主要用来绘制贪吃蛇地图
class Map
{
/// <summary>
/// 地图块类型
/// </summary>
/* enum TileType 想了想,做成枚举值,太麻烦,还是做成常量
{
Blank,
Wall,
Food,
}*/
public const int Blank = 0;
public const int Wall = 1;
public const int Food = 2;
//边缘一圈是墙
int[,] map = new int[20, 20]
{
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,},
};
/// <summary>
/// 存放逻辑处理(数据运算)
/// </summary>
public void Update()
{
//抛出异常
throw new NotImplementedException(); //未实现的异常
}
/// <summary>
/// 图形绘制
/// </summary>
public void Draw()
{
for(int i = 0;i < map.GetLength(0); i++) //行
{
for(int j=0;j< map.GetLength(1); j++) //列
{
Console.SetCursorPosition(j,i);
//关于颜色的设置
//前景色和背景色
Console.ForegroundColor = ConsoleColor.Yellow;
Console.BackgroundColor = ConsoleColor.Red;
//只有中文的空格,长宽才是一样的
Console.Write(" ");
}
}
}
}
}
之后我们建立两个单例