Example #1
0
      public static void Input()
             
      {
          ConsoleKeyInfo tombol = new ConsoleKeyInfo();

          Console.SetCursorPosition(30, 20);
                      if (Console.KeyAvailable)
          {
                          {
                  tombol = Console.ReadKey();

                  isKeyPressed = true;
              }
          }
          else
          {
              isKeyPressed = false;
          }

          if (tombol.Key == ConsoleKey.LeftArrow && !t.cekkiri() && isKeyPressed)
          {
                          {
                  for (int i = 0; i < 4; i++)
                  {
                      t.location[i][1] -= 1;
                                     
                  }
                  t.Update();
                             
              }
          }
          else if (tombol.Key == ConsoleKey.RightArrow && !t.cekkanan() && isKeyPressed)
          {
              for (int i = 0; i < 4; i++)
              {
                  t.location[i][1] += 1;
              }
              t.Update();
          }
          if (tombol.Key == ConsoleKey.DownArrow && isKeyPressed)
          {
              t.Drop();
                         
          }

          if (tombol.Key == ConsoleKey.Spacebar && isKeyPressed)
          {
                              t.Rotate();

              t.Update();
          }
      }