in WhackAMole.UWPClient/Controls/MoleControl.cs [180:223]
public void UpdatePosition()
{
var newX = Position.X + _vector.X;
var newY = Position.Y + _vector.Y;
if (newY > _maxTransformY || newY < 0)
{
var y = (newY < 0) ? 0 : _maxTransformY;
Position = new Point(Position.X, y); ;
_vector.Y = _vector.Y * -1;
}
else
{
Position = new Point(Position.X, newY);
if (_maxTransformY - newY <= _displayBorder.ActualHeight + 50 && (DisplayAlignment == MoleAlignment.BottomLeft || DisplayAlignment == MoleAlignment.BottomRight))
DisplayAlignment = (DisplayAlignment == MoleAlignment.BottomLeft) ? MoleAlignment.TopLeft : MoleAlignment.TopRight;
if (newY < _displayBorder.ActualHeight + 50 && (DisplayAlignment == MoleAlignment.TopRight || DisplayAlignment == MoleAlignment.TopLeft))
DisplayAlignment = (DisplayAlignment == MoleAlignment.TopRight) ? MoleAlignment.BottomRight : MoleAlignment.BottomLeft;
}
if (newX > _maxTransformX || newX < 0)
{
var x = (newX < 0) ? 0 : _maxTransformX;
Position = new Point(x, Position.Y);
_vector.X = _vector.X * -1;
}
else
{
Position = new Point(newX, Position.Y);
if (_maxTransformX - newX <= _displayBorder.ActualWidth + 50 && (DisplayAlignment == MoleAlignment.BottomRight || DisplayAlignment == MoleAlignment.TopRight))
DisplayAlignment = (DisplayAlignment == MoleAlignment.BottomRight) ? MoleAlignment.BottomLeft : MoleAlignment.BottomRight;
if (newX < _displayBorder.ActualWidth + 50 && (DisplayAlignment == MoleAlignment.TopLeft || DisplayAlignment == MoleAlignment.BottomLeft))
DisplayAlignment = (DisplayAlignment == MoleAlignment.TopLeft) ? MoleAlignment.TopRight : MoleAlignment.BottomRight;
}
}