crossEy3 Posted November 5, 2013 Share Posted November 5, 2013 Hi there, I'm hoping you wouldn't mind helping me with something... Is there a way to calculate the angle between two points then make the mouse move on this angle but a greater distance? The mini map is scaled down with ratio between the main screen and map is 8:1. The first point i guess the origin is known and fixed (center of mini map), but the FindColor function would find the second point and from these find the angle if that is possible. Apologies for the rambling too. I hope I explained myself well enough. Quote Link to comment Share on other sites More sharing options...
slacky Posted November 5, 2013 Share Posted November 5, 2013 (edited) The minimap does not have the same perspective as the mainscreen, so something like that without some complex 3D-perspective projection will be quite a bit off, I am afraid. But if you still want to try it there are several ways to do it for just simple scaling: 1. Use OSI, as it has MMToMS (MinimapToMainScreen)-function. 2. Simple maths Find the points on the minimap that you are interested substract the center of the minimap from those points, and do some simple multiplication: If the scale is 8:1 then you simple multiplay each point by eight, and move am to the center of the mainscreen. Pseudocode: const MMCenterX = 650; //Not exactly the center.. but using it for the sake of example MMCenterY = 650; MSCenterX = 350; //Not exactly the center.. but using it for the sake of example MSCenterY = 350; MMSCALE = 8; function MMToMS(PointOnMM:TPoint): TPoint; //Not 100% sure this will work, you will just have to test.. var pt:TPoint; begin pt.x := (PointOnMM.x - MMCenterX); pt.y := (PointOnMM.y - MMCenterY); pt.x := (pt.x * MMSCALE) + MSCenterX; pt.y := (pt.y * MMSCALE) + MSCenterY; Result := pt; end; 3. The harder way to do it... It is much more complicated.. const MMCenterX = 650; //Not exactly the center.. but using it for the sake of example MMCenterY = 650; MSCenterX = 350; //Not exactly the center.. but using it for the sake of example MSCenterY = 350; RadiusOfMM = 75; //Around 75px i am guessing... MMSCALE = 8; function ScalePoint(const Center, Pt:TPoint; Radius:Integer): TPoint; var dx,dy: Integer; Angle: Single; begin dx := (Center.X - Pt.X); dy := (Center.Y - Pt.Y); Angle := ArcTan2(dy, dx) + PI; Result.x := Round(Radius * Cos(Angle)) + Center.X; Result.y := Round(Radius * Sin(Angle)) + Center.Y; end; function MMToMS(PointOnMM:TPoint): TPoint; var pt:TPoint; begin //.. this is pretty uncomplete (will not work witout putting some more tought in to it).. pt := ScalePoint(Point(MMCenterX,MMCenterY), PointOnMM, RadiusOfMM*MMSCALE); //You might have to do some changes.. pt.x := (pt.x - MMCenterX) + MSCenterX; pt.y := (pt.y - MMCenterX) + MSCenterY; end; Note: This is still just untested pascal-like pseudo-code ("fake" code)... You will have to do the rest your self. Edited January 12, 2014 by slacky Quote Link to comment Share on other sites More sharing options...
crossEy3 Posted January 3, 2014 Author Share Posted January 3, 2014 (edited) Hi, Thanks very much slacky for your help and apologies for the delay in replying to your postie. Much appreciated man! I'll let you know what comes of it. :) Edited January 3, 2014 by crossEy3 Quote Link to comment Share on other sites More sharing options...
crossEy3 Posted January 8, 2014 Author Share Posted January 8, 2014 (edited) This may seem like a delineation from the original topic but it is related. Do Tpoints have to be integers or can you make them extended with decimal numbers being stored? For instance if the scale were 8.3 could this be carried through without rounding the Tpoints? I am new to using scar so I am probably saying stuff all wrong. The mmtoms thing works very well and its extremely close to hitting the nail on the head. Edited January 9, 2014 by crossEy3 typo Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted January 9, 2014 Share Posted January 9, 2014 TPoints cannot be anything other than integers because each pixel has a whole number and there are not half pixels. Quote Link to comment Share on other sites More sharing options...
Janilabo Posted January 9, 2014 Share Posted January 9, 2014 SCAR 4.0 has TPointF, which supports parameters (coordinates) as extended's, but it is not available in SCAR 3.X series. You can always recreate it yourself to 3.X, of course.. Easy task. However, none of the built-in functions support TPointF, so... You would have to write your own functions too. Quote Link to comment Share on other sites More sharing options...
slacky Posted January 10, 2014 Share Posted January 10, 2014 TPoint is just a record type. You can easily define your own record to hold floating point values: type TPointF = record x,y:Extended; end; var pt: TPointF; begin pt.x := 123.456; pt.y := 789.012; WriteLn(TEAToStr([pt.x, pt.y])); end. I don't see much use for such a record, except in more advanced math. Quote Link to comment Share on other sites More sharing options...
crossEy3 Posted January 12, 2014 Author Share Posted January 12, 2014 (edited) Thanks alot for the info guys. The reason i askd was after finding out about mmtoms i did some experimenting and such and was reading other stuff about it. I came across a post in another forums saying how if the tpoints were stored as [ext,ext] rather than integers it would be much more accurate. I might ave misunderstood him though which is quite likely. Thanks again for the help and feel free to close the thread. I keep tweaking stuff and it gets closer and closer to being spot on. Also... this is my first time learning any form of program language and you guys have made it pure easy to understand with all the tutorials and stuff. Nice one, glad I stumbled upon this. Edited January 12, 2014 by crossEy3 Quote Link to comment Share on other sites More sharing options...