public void UpdateVelocity(DotPosition dotPosition, Velocity velocity) { if ((dotPosition.X == X || dotPosition.X == _x1) && (dotPosition.Y == Y || dotPosition.Y == _y1)) { velocity.InvertBoth(); return; } if (dotPosition.X == X || dotPosition.X == _x1) { velocity.InvertX(); return; } if (dotPosition.Y == Y || dotPosition.Y == _y1) { velocity.InvertY(); return; } throw new InvalidOperationException("This shouldn't happen"); }
public static bool AnyHitBy(DotPosition dotPosition) => obstacles.Any(o => o.Hits(dotPosition));
public bool Hits(DotPosition dotPosition) => dotPosition.X >= X && dotPosition.X <= _x1 && dotPosition.Y >= Y && dotPosition.Y <= _y1;