Advertisement
Nausa

Movement

Nov 19th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1.  static public void dMain()
  2.         {
  3.        
  4.         int x = 5;
  5.         int y = 5;
  6.  
  7.         int xa; ;
  8.             int ya; ;
  9.  
  10.          
  11.              
  12.         xa = x;
  13.                 ya = y;
  14.                 Press(ref x, ref y);
  15.  
  16.  
  17.     }
  18.  
  19.  
  20.  
  21. static void Press(ref int x1, ref int y1)
  22. {
  23.  
  24.     ConsoleKeyInfo info = Console.ReadKey();
  25.  
  26.     string b = info.Key.ToString();
  27.     switch (b)
  28.     {
  29.         case ("W"):
  30.             y1 = y1 - 1;
  31.             if (y1 == 0)
  32.             {
  33.                 y1 = 10;
  34.  
  35.             }
  36.  
  37.             break;
  38.  
  39.         case ("S"):
  40.             y1 = y1 + 1;
  41.             if (y1 >= 11)
  42.             {
  43.                 y1 = 1;
  44.  
  45.             }
  46.  
  47.             break;
  48.  
  49.         case ("D"):
  50.             x1 = x1 + 1;
  51.             if (x1 >= 11)
  52.             {
  53.                 x1 = 1;
  54.             }
  55.  
  56.             break;
  57.  
  58.  
  59.         case ("A"):
  60.             x1 = x1 - 1;
  61.             if (x1 <= 0)
  62.             {
  63.                 x1 = 10;
  64.  
  65.             }
  66.  
  67.             break;
  68.  
  69.         default:
  70.             break;
  71.     }
  72. }
  73. //
  74.  
  75.  
  76.  
  77. static void Change(ref char[,] map_change, int x1, int y1, int x2, int y2)
  78. {
  79.     char helper;
  80.     helper = map_change[y1 - 1, x1 - 1];
  81.     map_change[y1 - 1, x1 - 1] = map_change[y2 - 1, x2 - 1];
  82.     map_change[y2 - 1, x2 - 1] = helper;
  83.    
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement