Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #17 from AlessioDP/jump-fix
Browse files Browse the repository at this point in the history
Fix minimap jumps
  • Loading branch information
CptWesley authored Oct 7, 2021
2 parents e24aff1 + 17a08f9 commit 412e278
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/NewWorldMinimap/MapForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,32 @@ private void UpdateLoop()
{
Stopwatch sw = new Stopwatch();

Vector3 lastPos = Vector3.Zero;
int jumpThreshold = int.MaxValue;
int i = 0;
while (true)
{
sw.Restart();

if (pd.TryGetPosition(ScreenGrabber.TakeScreenshot(currentScreen), out Vector3 pos))
{
Console.WriteLine($"{i}: {pos}");
Vector3 difference = lastPos - pos;
Console.WriteLine($"{i}: {pos} [{difference.Length()}]");
if (difference.Length() > 20.0)
{
if (jumpThreshold < 3)
{
Console.WriteLine($"{i}: Failure due to jump of {difference.Length()}");
jumpThreshold++;
continue;
}
else
{
jumpThreshold = 0;
}
}

lastPos = pos;
using Image<Rgba32> baseMap = map.GetTileForCoordinate(pos.X, pos.Y);

(int imageX, int imageY) = map.ToMinimapCoordinate(pos.X, pos.Y, pos.X, pos.Y);
Expand Down

0 comments on commit 412e278

Please sign in to comment.