夜光带你走进C# 游戏开发等(七十)擅长的领域

夜光序言:

 

有时候会怀疑,支离破碎的我们如何拼凑后来的结局的完整,可是我们,其实是被保护得太完整。

 

 

 

 

 

 

 

正文:今日的课题

 

怎么做呢~

首先,我们需要程序编写一个地图

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(" ");

                }
            }
        }

    }
}

 

 

 

之后我们建立两个单例

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值