public void Process(ConsoleKeyInfo pressedButton) { switch (pressedButton.Key) { case ConsoleKey.UpArrow: worm.Clear(); worm.DX = 0; worm.DY = -1; worm.Draw(); wall.Draw(); break; case ConsoleKey.DownArrow: worm.Clear(); worm.DX = 0; worm.DY = 1; worm.Draw(); wall.Draw(); break; case ConsoleKey.LeftArrow: worm.Clear(); worm.DX = -1; worm.DY = 0; worm.Draw(); wall.Draw(); break; case ConsoleKey.RightArrow: worm.Clear(); worm.DX = 1; worm.DY = 0; worm.Draw(); wall.Draw(); break; case ConsoleKey.Escape: Environment.Exit(0); break; case ConsoleKey.F2: worm.Save(); food.Save(); break; case ConsoleKey.F1: worm = worm.Load() as Worm; food = food.Load() as Food; break; } }
public Game() { isAlive = true; gameLevel = GameLevel.First; worm = new Worm(new Point { X = 10, Y = 10 }, ConsoleColor.White, '*'); food = new Food(new Point { X = 20, Y = 10 }, ConsoleColor.White, '+'); wall = new Wall(null, ConsoleColor.White, '#'); wall.LoadLevel(GameLevel.First); g_objects.Add(worm); g_objects.Add(food); g_objects.Add(wall); }
public Game() { isAlive = true; worm = new Worm(new Point { X = 10, Y = 10 }, ConsoleColor.Green, '■'); food = new Food(new Point { X = r.Next(0, 34), Y = r.Next(0, 34) }, ConsoleColor.Red, '$'); wall = new Wall(null, ConsoleColor.DarkBlue, '■'); ChangeLvL(); g_objects.Add(worm); g_objects.Add(food); g_objects.Add(wall); }