void IPixel.Play(ref int score, ref bool gameover, IPixel head, ref IPixel berry) { do { Clear(); gameover |= head.XPosition == WindowWidth - 1 || head.XPosition == 0 || head.YPosition == WindowHeight - 1 || head.YPosition == 0; head.Score(ref score, head, ref berry); for (int i = 0; i < body.Count; i++) { head.DrawPixel(body[i]); gameover |= body[i].XPosition == head.XPosition && body[i].YPosition == head.YPosition; } if (gameover) { break; } head.DrawPixel(head); berry.DrawPixel(berry); const int milliseconds = 500; Stopwatch stopWatch = Stopwatch.StartNew(); while (stopWatch.ElapsedMilliseconds <= milliseconds) { currentMovement = Direction.ReadMovement(currentMovement); } body.Add(new Pixel(head.XPosition, head.YPosition, ConsoleColor.Green)); Direction.Choice(head, currentMovement); if (body.Count > score) { body.RemoveAt(0); } }while (true); }