Ejemplo n.º 1
0
 public void elapsed(object sender, ElapsedEventArgs e)
 {
     if (Butter.gameOver)
     {
         gameover();
     }
     else
     {
         if (Butter.score == 2)
         {
             timer.Enabled = !timer.Enabled;
             Nextlvl.Serialize(2, Butter.username, 20, 20, 1, 3);
             System.Diagnostics.Process.Start(System.AppDomain.CurrentDomain.FriendlyName);
             Environment.Exit(0);
         }
         else
         if (Butter.score == 5)
         {
             timer.Enabled = !timer.Enabled;
             Nextlvl.Serialize(3, Butter.username, 20, 20, 1, 6);
             System.Diagnostics.Process.Start(System.AppDomain.CurrentDomain.FriendlyName);
             Environment.Exit(0);
         }
         worm.Clear();
         worm.Move();
         worm.Draw();
         CheckCollision();
     }
 }
Ejemplo n.º 2
0
 public static void gameover()
 {
     if (Butter.gameOver)
     {
         Nextlvl.Serialize(1, "n", 20, 20, 0, -1);
         Console.SetCursorPosition(15, 34);
         Console.WriteLine("Game over!");
         Console.WriteLine(Butter.username + " your score: " + Butter.score);
         Console.WriteLine("Press R to reset the game!");
         Console.WriteLine("Press ESC to save your record and close the game!");
     }
 }
Ejemplo n.º 3
0
        public void ProcessKeyEvent(ConsoleKeyInfo consoleKeyInfo)
        {
            switch (consoleKeyInfo.Key)
            {
            case ConsoleKey.UpArrow:
                worm.dx = 0;
                worm.dy = -1;
                break;

            case ConsoleKey.DownArrow:
                worm.dx = 0;
                worm.dy = 1;
                break;

            case ConsoleKey.RightArrow:
                worm.dx = 1;
                worm.dy = 0;
                break;

            case ConsoleKey.LeftArrow:
                worm.dx = -1;
                worm.dy = 0;
                break;

            case ConsoleKey.Escape:
                timer.Enabled = !timer.Enabled;
                Savescore.Serialize();
                Nextlvl.Serialize(1, "n", 20, 20, 0, -1);
                Environment.Exit(0);
                break;

            case ConsoleKey.R:
                System.Diagnostics.Process.Start(System.AppDomain.CurrentDomain.FriendlyName);
                Environment.Exit(0);
                break;
            }
        }