Пример #1
0
 public void MoveBadgays()
 {
     while ((dir == 1 && X != Console.BufferWidth) || (dir == -1 && X != 0))
     {
         bool hitme = false;
         AddingMethods.WriteTo(X, Y, badchar[X % 4]);
         for (int i = 0; i < 15; i++)
         {
             Thread.Sleep(40);
             if (AddingMethods.ReadTo(X, Y) == '*')
             {
                 hitme = true;
                 break;
             }
         }
         AddingMethods.WriteTo(X, Y, ' ');
         if (hitme)
         {
             Console.Beep();
             Interlocked.Increment(ref Program.hit);
             AddingMethods.score();
             Thread.CurrentThread.Abort();
         }
         X += dir;
     }
     Interlocked.Increment(ref Program.miss);
     AddingMethods.score();
 }
Пример #2
0
        static public void CreateBullet(object o)
        {
            int x = (int)o;

            if (AddingMethods.ReadTo(x, Console.BufferHeight - 2) == '*')
            {
                return;
            }
            if (!Program.bulletsem.WaitOne(0))
            {
                return;
            }
            new Thread(new Bullet(x).MoveBullet).Start();
        }