码迷,mamicode.com
首页 > 移动开发 > 详细

迷宫移动

时间:2015-09-17 21:25:46      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:

{"■","■","■","■","■","■","■","■","■"," ","■"},
{"■"," "," "," "," "," "," "," "," "," ","■"},
{"■"," "," ","■","■"," "," "," "," "," ","■"},
{"■"," ","■"," "," ","■"," "," "," "," ","■"},
{"■"," ","■"," "," "," ","■"," "," "," ","■"},
{"■"," ","■"," "," "," ","■"," "," "," ","■"},
{"■"," ","■"," ","■"," ","■"," "," "," ","■"},
{"■"," ","■"," ","■"," ","■"," "," "," ","■"},
{"■"," ","■"," ","■"," ","■"," "," ","■","■"},
{"■"," ","■"," ","■"," "," ","■","■"," ","■"},
{"■"," "," "," ","■"," "," "," "," "," ","■"},
{"■","■","■","■","■","■","■","■","■","■","■"}
};

int reny = 9;
int renx = 9;
erwei[reny, renx] = "人";

while (true)
{
for (int j = 0; j < 12; j++)
{
for (int i = 0; i < 11; i++)
{
Console.Write(erwei[j, i]);
}
Console.Write("\n");
}

erwei[reny, renx] = " ";
Console.Write("请输入:");
string caozuo = Console.ReadLine();
if (caozuo == "w")
{
if (erwei[reny - 1, renx] == " ")
{
reny = reny - 1;
}
}
if (caozuo == "a")
{
if (erwei[reny, renx - 1] == " ")
{
renx = renx - 1;
}
}
if (caozuo == "s")
{
if (erwei[reny + 1, renx] == " ")
{
reny = reny + 1;
}
}
if (caozuo == "d")
{
if (erwei[reny, renx + 1] == " ")
{
renx = renx + 1;
}
}

erwei[reny, renx] = "人";
Console.Clear();
if (reny == 0 && renx == 9)
{
Console.Write("游戏结束");
break;
}


}
Console.ReadLine();

迷宫移动

标签:

原文地址:http://www.cnblogs.com/name-hanlin/p/4817560.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!