Author Topic: Math issues with Radar putting object positions in the area  (Read 613 times)

The radar is done, but..

What I am trying to do is when the range is changed the math changes for the object.

The image extent is 200 200, and the main swatch extent is 300 300. The image is positioned at the center of the swatch, which is 50 50

This loop here updates all the existing objects in case the main player moves in a different direction.

The %newPos is where to look at because that is how it gets moved.
%obj.worldPos is the actual positions from the server, it is being translated to fit into the circle.
In cyan, is the main part of the position of how it changes.

%transform = serverconnection.getcontrolob ject().gettransform();
%rx = getword(%transform, 0);
%ry = getword(%transform, 1);

if(%obj $= "")
{
   for(%i=0;%i<%this.getCount();%i++)
   {
      %obj = %this.getObject(%i);
      %px = %rx - getword(%obj.worldPos, 0);
      %py = %ry - getword(%obj.worldPos, 1);
      %pdist = msqrt((%py * %py) + (%px * %px));
      %moveDist = -1 * mpow(1.07, (%pdist * -0.2)) + 1; //I don't want to ever change this because I don't really know how this works

      %newPos = mFloor((220 - $vRadar::Range) * mcos(matan(%py, %px) - %transform_pi) * %moveDist + (%vRadar["Img","Extent","X"] * msqrt(2))) SPC
            mFloor((220 - $vRadar::Range) * msin(matan(%py, %px) - %transform) * %moveDist + (%vRadar["Img","Extent","Y"] * msqrt(2)));


      if($Sim::Time - %obj.lastResponse > $vRadar::Timeout) //Did it get a response?
      {
         %obj.delete();
         %i--;
      }
      else if(%newPos !$= %obj.position)
      {
         %obj.resize(getWord(%newPos, 0), getWord(%newPos, 1), 20 * $Pref::Client::vRadar_Size, 20 * $Pref::Client::vRadar_Size);
         //echo(%obj.getName() @ " - Dist: " @ vRadar_getDist(%obj));
      }
   }
}


Here is how it looks. (Click the picture to see a video)

Nevermind, I figured out the math for it to work. I'll show the code soon and a new video.