星空网 > 软件开发 > ASP.net

迷宫移动

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

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




原标题:迷宫移动

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流