• 迷宫移动


     1 string[,] erwei = new string[12, 11] 
     2             {
     3                 {"","","","","","","","","","  ",""}, 
     4                 {"","  ","  ","  ","  ","  ","  ","  ","  ","  ",""}, 
     5                 {"","  ","  ","","","  ","  ","  ","  ","  ",""},
     6                 {"","  ","","  ","  ","","  ","  ","  ","  ",""},
     7                 {"","  ","","  ","  ","  ","","  ","  ","  ",""},
     8                 {"","  ","","  ","  ","  ","","  ","  ","  ",""},
     9                 {"","  ","","  ","","  ","","  ","  ","  ",""},
    10                 {"","  ","","  ","","  ","","  ","  ","  ",""},
    11                 {"","  ","","  ","","  ","","  ","  ","",""},
    12                 {"","  ","","  ","","  ","  ","","","  ",""},
    13                 {"","  ","  ","  ","","  ","  ","  ","  ","  ",""},
    14                 {"","","","","","","","","","",""} 
    15             };
    16 
    17             int reny = 9;
    18             int renx = 9;
    19             erwei[reny, renx] = "";
    20 
    21             while (true)
    22             {
    23                 for (int j = 0; j < 12; j++)
    24                 {
    25                     for (int i = 0; i < 11; i++)
    26                     {
    27                         Console.Write(erwei[j, i]);
    28                     }
    29                     Console.Write("
    ");
    30                 }
    31 
    32                 erwei[reny, renx] = "  ";
    33                 Console.Write("请输入:");
    34                 string caozuo = Console.ReadLine();
    35                 if (caozuo == "w")
    36                 {
    37                     if (erwei[reny - 1, renx] == "  ")
    38                     {
    39                         reny = reny - 1;
    40                     }
    41                 }
    42                 if (caozuo == "a")
    43                 {
    44                     if (erwei[reny, renx - 1] == "  ")
    45                     {
    46                         renx = renx - 1;
    47                     }
    48                 }
    49                 if (caozuo == "s")
    50                 {
    51                     if (erwei[reny + 1, renx] == "  ")
    52                     {
    53                         reny = reny + 1;
    54                     }
    55                 }
    56                 if (caozuo == "d")
    57                 {
    58                     if (erwei[reny, renx + 1] == "  ")
    59                     {
    60                         renx = renx + 1;
    61                     }
    62                 }
    63                
    64                 erwei[reny, renx] = "";
    65                 Console.Clear();
    66                 if (reny == 0 && renx == 9)
    67                 {
    68                     Console.Write("游戏结束,已逃脱!");
    69                     break;
    70                 }
    71                     
    72 
    73               
    74             }
    75             Console.ReadLine();
  • 相关阅读:
    二级域名绑定子目录
    Promise.all的使用
    react的状态管理
    chrome调试
    组件之间通讯
    promise-async-await
    深入理解AMQP协议转载
    java中堆栈(stack)和堆(heap)
    面试题(Spring)
    IO复用,AIO,BIO,NIO,同步,异步,阻塞和非阻塞 区别参考
  • 原文地址:https://www.cnblogs.com/name-hanlin/p/4817560.html
Copyright © 2020-2023  润新知