迷宫移动
2015-09-17 20:24
375 查看
string[,] erwei = new string[12, 11] { {"■","■","■","■","■","■","■","■","■"," ","■"}, {"■"," "," "," "," "," "," "," "," "," ","■"}, {"■"," "," ","■","■"," "," "," "," "," ","■"}, {"■"," ","■"," "," ","■"," "," "," "," ","■"}, {"■"," ","■"," "," "," ","■"," "," "," ","■"}, {"■"," ","■"," "," "," ","■"," "," "," ","■"}, {"■"," ","■"," ","■"," ","■"," "," "," ","■"}, {"■"," ","■"," ","■"," ","■"," "," "," ","■"}, {"■"," ","■"," ","■"," ","■"," "," ","■","■"}, {"■"," ","■"," ","■"," "," ","■","■"," ","■"}, {"■"," "," "," ","■"," "," "," "," "," ","■"}, {"■","■","■","■","■","■","■","■","■","■","■"} }; 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();
相关文章推荐
- C语言预处理那些事
- iOS疯狂讲解之加载视图的好处
- Android开发主要知识点总结
- 项目构建工具Maven的学习笔记
- 冒泡排序和3个数比较大小思想
- OC部分知识点(2)
- 跳槽季:分享从事C#开发人员面试经验
- XUtils开源项目---BitmapUtils图片处理
- Android 平台下使用 i2c-tools
- CodeForces-489C Given Length and Sum of Digits...
- UITableViewCell复用后,label上的字重叠的问题
- android图形图像处理PorterDuffXfermode
- hdu 1106 排序
- oracle 多表关联更新,需要更新的字段在另一个表里
- hsqldb数据库
- usaco Contact
- threejs加载图片需创站与 如何写出字体
- IPMI从驱动到应用(中篇 )
- OC部分知识点
- 谷歌官方建议笔记——性能