public void Update() { switch (direction) { case 0: { if (map.IsBrick((int)(snake.Head.Position.X - distance) / 30, (int)(snake.Head.Position.Y / 30))) { GameStop(); } else { if (world.Food.Eat((int)(snake.Head.Position.X - snake.Speed) / 30, (int)(snake.Head.Position.Y / 30))) { world.Food.ChangePosition(map.Available, snake.Positions); snake.Grow(); Score.UpdateScore(world.Food.Points); AddPosition((int)snake.Head.Position.X, (int)snake.Head.Position.Y); } if (snake.Canibalism(snake.Head.Position.X - snake.Speed, snake.Head.Position.Y)) { GameStop(); } snake.MoveLeft(); UpdatePositions((int)snake.Head.Position.X, (int)snake.Head.Position.Y); } break; } case 1: { if (map.IsBrick((int)((snake.Head.Position.X + distance) / 30), (int)(snake.Head.Position.Y / 30))) { GameStop(); } else { if (world.Food.Eat((int)(snake.Head.Position.X + snake.Speed) / 30, (int)(snake.Head.Position.Y / 30))) { world.Food.ChangePosition(map.Available, snake.Positions); snake.Grow(); Score.UpdateScore(world.Food.Points); AddPosition((int)snake.Head.Position.X, (int)snake.Head.Position.Y); } if (snake.Canibalism(snake.Head.Position.X + snake.Speed, snake.Head.Position.Y)) { GameStop(); } snake.MoveRight(); UpdatePositions((int)snake.Head.Position.X, (int)snake.Head.Position.Y); } break; } case 2: { if (map.IsBrick((int)(snake.Head.Position.X) / 30, (int)((snake.Head.Position.Y - distance) / 30))) { GameStop(); } else { if (world.Food.Eat((int)(snake.Head.Position.X / 30), (int)((snake.Head.Position.Y - snake.Speed) / 30))) { world.Food.ChangePosition(map.Available, snake.Positions); snake.Grow(); Score.UpdateScore(world.Food.Points); AddPosition((int)snake.Head.Position.X, (int)snake.Head.Position.Y); } if (snake.Canibalism(snake.Head.Position.X, snake.Head.Position.Y - snake.Speed)) { GameStop(); } snake.MoveUp(); UpdatePositions((int)snake.Head.Position.X, (int)snake.Head.Position.Y); } break; } case 3: { if (map.IsBrick((int)(snake.Head.Position.X) / 30, (int)((snake.Head.Position.Y + distance) / 30))) { GameStop(); } else { if (world.Food.Eat((int)(snake.Head.Position.X) / 30, (int)((snake.Head.Position.Y + snake.Speed) / 30))) { world.Food.ChangePosition(map.Available, snake.Positions); snake.Grow(); Score.UpdateScore(world.Food.Points); AddPosition((int)snake.Head.Position.X, (int)snake.Head.Position.Y); } if (snake.Canibalism(snake.Head.Position.X, snake.Head.Position.Y + snake.Speed)) { GameStop(); } snake.MoveDown(); UpdatePositions((int)snake.Head.Position.X, (int)snake.Head.Position.Y); } break; } default: break; } }