public void Process(ConsoleKeyInfo pressedButton) { switch (pressedButton.Key) { case ConsoleKey.LeftArrow: worm.DY = 0; worm.DX = -1; break; case ConsoleKey.RightArrow: worm.DY = 0; worm.DX = 1; break; case ConsoleKey.UpArrow: worm.DY = -1; worm.DX = 0; break; case ConsoleKey.DownArrow: worm.DY = 1; worm.DX = 0; break; case ConsoleKey.Spacebar: if (isPaused) { isPaused = false; Start(); } else { isPaused = true; Stop(); } break; case ConsoleKey.F1: if (isPaused) { pts = points; l = lev; worm.Save(); food.Save(); wall.Save(); } break; case ConsoleKey.F2: if (isPaused) { Console.Clear(); DrawField(); points = pts; lev = l; worm = worm.Load() as Worm; food = food.Load() as Food; wall = wall.Load() as Wall; Draw(); } break; case ConsoleKey.Escape: alive = false; Stop(); DrawGameOver(); break; default: break; } }
public void Save() { worm.Save(); wall.Save(); }