Advertisement
VidarBroberg

ENKELT.

Oct 28th, 2021
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.21 KB | None | 0 0
  1.  
  2. namespace BreakOut
  3. {
  4.     class MyProgram
  5.     {
  6.         public void Run()
  7.         {  
  8.             #region Platform
  9.             for (int i = 45; i < 50; i++)
  10.             {
  11.  
  12.  
  13.                 System.Threading.Thread.Sleep(15);
  14.                 Console.SetCursorPosition(i, 17);
  15.                 Console.Write("##");
  16.  
  17.  
  18.             }
  19.  
  20.  
  21.  
  22.  
  23.             #endregion
  24.  
  25.  
  26.  
  27.             #region walls
  28.  
  29.             for (int i = 100; i > 0; i--)
  30.             {
  31.                 Console.SetCursorPosition(i, 1);
  32.                 Console.WriteLine("█");
  33.  
  34.  
  35.             }
  36.             for (int i = 17; i > 0; i--)
  37.             {
  38.                 Console.SetCursorPosition(100, i);
  39.                 Console.WriteLine("█");
  40.  
  41.  
  42.             }
  43.  
  44.  
  45.             for (int i = 17; i > 0; i--)
  46.             {
  47.                 Console.SetCursorPosition(1, i);
  48.                 Console.WriteLine("█");
  49.  
  50.  
  51.             }
  52.            
  53.             #endregion
  54.  
  55.  
  56.  
  57.  
  58.             #region Directions
  59.             int posX = 5;
  60.             int posY = 15;
  61.             int directionX = 1;
  62.             int directionY = 1;
  63.             bool isRunning = true;
  64.             while (isRunning)
  65.             {
  66.                 Console.SetCursorPosition(posX, posY);
  67.                 Console.WriteLine(" ");
  68.                 posX = posX + directionX;
  69.                 if (posX <= 4 || posX >= 99)
  70.                 {
  71.                     directionX = directionX * -1;
  72.                 }
  73.                 Console.SetCursorPosition(posX, posY);
  74.                 Console.WriteLine("O");
  75.                 System.Threading.Thread.Sleep(5);
  76.  
  77.  
  78.                 Console.SetCursorPosition(posX, posY);
  79.                 Console.WriteLine(" ");
  80.                 posY = posY + directionY;
  81.                 if(posY <=2 || posY >=16)
  82.                 {
  83.                     directionY = directionY * -1;
  84.                 }
  85.                 Console.SetCursorPosition(posX, posY);
  86.                 Console.WriteLine("O");
  87.                 System.Threading.Thread.Sleep(100);
  88.  
  89.  
  90.             }
  91.  
  92.  
  93.  
  94.  
  95.  
  96.             #endregion
  97.  
  98.  
  99.            
  100.         }
  101.  
  102.  
  103.  
  104.  
  105.  
  106.            
  107.  
  108.             #region Bricks
  109.            
  110.  
  111.  
  112.  
  113.             #endregion
  114.  
  115.  
  116.         }
  117.  
  118.     }
  119.  
  120.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement