Beispiel #1
0
 void GameTick(object sender, EventArgs e)
 {
     if (!paused && !G.gameOver)
     {
         timePassed += timer.Interval;
         if (timePassed >= timeForTurn)
         {
             G.Down();
             timePassed = 0;
             if (G.score > level * scorePerLevel && level <= 20)
             {
                 SetLevel(level + 1);
                 timeForTurn -= 20;
             }
         }
     }
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            ConsoleKey c;

/*			play.pField = new int[]{
 *                              0,0,0,0,0,0,0,0,0,0,0,0,
 *                              0,0,0,0,0,0,0,0,0,0,0,0,
 *                              0,0,0,0,0,0,0,0,0,0,0,0,
 *                              0,0,0,0,0,0,0,0,0,0,0,0,
 *                              0,0,0,0,0,0,0,0,0,0,0,0,
 *                              0,0,0,0,0,0,0,0,0,0,0,0,
 *                              0,0,0,0,0,0,0,0,0,0,0,0,
 *                              0,0,0,0,0,0,0,0,0,0,0,0,
 *                              0,0,0,0,0,0,0,0,0,0,0,0,
 *                              0,0,0,0,0,0,0,0,0,0,0,0,
 *                              0,0,0,0,0,0,2,0,0,0,0,0,
 *                              0,0,0,0,0,0,2,0,0,0,0,0,
 *                              0,0,0,0,0,0,2,2,0,0,0,0,
 *                              0,0,0,0,0,0,2,2,0,0,0,0,
 *                              0,0,0,0,0,0,2,2,2,0,0,0,
 *                              0,0,2,2,0,0,2,2,2,2,0,0,
 *                              2,2,2,2,2,2,2,2,2,2,2,2,
 *                              2,2,2,2,2,2,2,2,2,2,2,2,
 *                      };
 */         play.PrintPiece();
            Show();
            Timer timer = new Timer(TimerCallback, null, 0, 1000);

            while (!play.isGameOver())
            {
                if (Console.KeyAvailable)
                {
                    c = Console.ReadKey().Key;

                    switch (c)
                    {
                    case ConsoleKey.UpArrow:
                        play.Up();
                        break;

                    case ConsoleKey.DownArrow:
                        play.Down();
                        break;

                    case ConsoleKey.LeftArrow:
                        play.Left();
                        break;

                    case ConsoleKey.RightArrow:
                        play.Right();
                        break;

                    case ConsoleKey.Enter:
                        play.Rotate();
                        break;

                    case ConsoleKey.P:
                        play.SweapPiecePosition();
                        play.GetCurrentPiece();
                        play.PrintPiece();
                        break;
                    }
                    Show();
                }
            }
            Show();
            Console.Read();
        }