资源简介
C#控制台编写的贪吃蛇,欢迎大家一起探讨学习,要积分是为了下其它东西,我也是被逼的!

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
namespace GluttonousSnake
{
class Map
{
Random ran = new Random();
public int length = 25;
public int wide = 25;
public char[] maps;
public int[] food;
///
/// 绘制出地图边界
///
public void DrawMap()
{
maps = new char[length wide];
for (int i = 0; i < maps.GetLength(0); i++)
{
for (int j = 0; j < maps.GetLength(1); j++)
{
if (i == 0|| j == 0 || j == maps.GetLength(1) - 1|| i == maps.GetLength(0) - 1)
{
maps[i j] = ‘▓‘;
}
else
{
maps[i j] = ‘ ‘;
}
}
}
}
///
/// 打印地图
///
public void PrintMap()
{
Console.Clear();
for (int i = 0; i < maps.GetLength(0); i++)
{
for (int j = 0; j < maps.GetLength(1); j++)
{
Console.SetCursorPosition(j * 2 i);
Console.Write(maps[i j]);
}
}
Console.CursorVisible = false;
}
///
/// 随机生成一个蛇
///
public void RandomSnake(Snake sn)
{
sn.snakeList = new List();
int x =ran.Next(1 length - 1);
int y =ran.Next(1 wide - 1);
for (int i = 0; i < sn.lenght; i++)
{
int[] xy = new int[2];
xy[0] = x;
xy[1] = y - i;
sn.snakeList.Add(xy);
//maps[xy[0] xy[1]] = “♀“;
maps[xy[0] xy[1]] = ‘♀‘;
Console.SetCursorPosition(xy[1]*2 xy[0]);
Console.Write(maps[xy[0] xy[1]]);
}
}
///
/// 随机一个食物
///
public void RandomFood(List snkeList)
{
int x=1;
int y=1;
bool bl = true;
while (bl)
{
x = ran.Next(1 length - 1);
y = ran.Next(1 wide - 1);
int i=0;
foreach (var item in snkeList)
{
if (item[0] == x && item[1] == y)
{
i++;
}
}
if (i==0)
{
bl = false;
}
}
food = new int[2];
food[0] = x;
food[1] = y;
maps[x y] = ‘〇‘;
Console.SetCursorPosition(y*2 x);
Console.Write(maps[x
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-28 20:15 GluttonousSnake\
目录 0 2018-05-28 20:15 GluttonousSnake\.vs\
目录 0 2018-05-28 20:15 GluttonousSnake\.vs\GluttonousSnake\
目录 0 2018-05-28 20:15 GluttonousSnake\.vs\GluttonousSnake\DesignTimeBuild\
文件 368916 2018-05-29 00:34 GluttonousSnake\.vs\GluttonousSnake\DesignTimeBuild\.dtbcache
目录 0 2018-05-28 20:15 GluttonousSnake\.vs\GluttonousSnake\v15\
文件 32256 2018-05-29 00:39 GluttonousSnake\.vs\GluttonousSnake\v15\.suo
目录 0 2018-05-28 20:15 GluttonousSnake\.vs\GluttonousSnake\v15\Server\
目录 0 2018-05-28 20:15 GluttonousSnake\.vs\GluttonousSnake\v15\Server\sqlite3\
文件 0 2018-05-27 10:34 GluttonousSnake\.vs\GluttonousSnake\v15\Server\sqlite3\db.lock
文件 634880 2018-05-29 00:19 GluttonousSnake\.vs\GluttonousSnake\v15\Server\sqlite3\storage.ide
文件 32768 2018-05-29 00:36 GluttonousSnake\.vs\GluttonousSnake\v15\Server\sqlite3\storage.ide-shm
文件 4144752 2018-05-29 00:34 GluttonousSnake\.vs\GluttonousSnake\v15\Server\sqlite3\storage.ide-wal
目录 0 2018-05-29 00:32 GluttonousSnake\GluttonousSnake\
文件 178 2018-05-27 10:33 GluttonousSnake\GluttonousSnake\GluttonousSnake.csproj
文件 3090 2018-05-28 23:35 GluttonousSnake\GluttonousSnake\Map.cs
文件 2186 2018-05-29 00:32 GluttonousSnake\GluttonousSnake\Program.cs
文件 9722 2018-05-28 23:38 GluttonousSnake\GluttonousSnake\Snake.cs
目录 0 2018-05-28 20:15 GluttonousSnake\GluttonousSnake\bin\
目录 0 2018-05-28 20:15 GluttonousSnake\GluttonousSnake\bin\Debug\
目录 0 2018-05-28 20:15 GluttonousSnake\GluttonousSnake\bin\Debug\netcoreapp2.0\
文件 477 2018-05-29 00:34 GluttonousSnake\GluttonousSnake\bin\Debug\netcoreapp2.0\GluttonousSnake.deps.json
文件 10752 2018-05-29 00:34 GluttonousSnake\GluttonousSnake\bin\Debug\netcoreapp2.0\GluttonousSnake.dll
文件 3804 2018-05-29 00:34 GluttonousSnake\GluttonousSnake\bin\Debug\netcoreapp2.0\GluttonousSnake.pdb
文件 248 2018-05-29 00:34 GluttonousSnake\GluttonousSnake\bin\Debug\netcoreapp2.0\GluttonousSnake.runtimeconfig.dev.json
文件 154 2018-05-29 00:34 GluttonousSnake\GluttonousSnake\bin\Debug\netcoreapp2.0\GluttonousSnake.runtimeconfig.json
目录 0 2018-05-29 00:34 GluttonousSnake\GluttonousSnake\obj\
目录 0 2018-05-28 20:15 GluttonousSnake\GluttonousSnake\obj\Debug\
目录 0 2018-05-28 20:15 GluttonousSnake\GluttonousSnake\obj\Debug\netcoreapp2.0\
文件 1028 2018-05-27 10:34 GluttonousSnake\GluttonousSnake\obj\Debug\netcoreapp2.0\GluttonousSnake.AssemblyInfo.cs
文件 42 2018-05-27 10:34 GluttonousSnake\GluttonousSnake\obj\Debug\netcoreapp2.0\GluttonousSnake.AssemblyInfoInputs.cache
............此处省略10个文件信息
- 上一篇:C#星号密码查看器
- 下一篇:asp.net(增删改查)
相关资源
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
- c#向word文件插入图片
- C#左侧导航菜单(动态生成)
评论
共有 条评论