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("\n");
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();