trojan
2011-05-10 07:18:02
Is there a function in SRL to see if the mouse is within co-ordinates, or a certain distance from a point? If not can these be added to the Includes?
If they already exist sorry for creating this post, I just couldn't find them anywhere :/
//Checks if the current mouse position is to the right of x1, left of x2, below y1 and above y2
//Example use if not MouseWithin(MIX1, MIY1, MIX2, MIY2) then MMouse(MIX1 + 15, MIY1 + 20, 5, 5);
Function MouseWithin(x1, y1, x2, y2 :integer) :boolean;
var
x, y:integer;
begin
Result := False;
GetMousePos(x, y);
if (x > x1) and (x < x2) then
if (y > y1) and (y < y2) then
Result := True;
end;
//Checks if the current mouse position is within a certain distance from the point specified
//an example use is if not MouseDistancePoint(MSCX, MSCY, 20) then MMouse(MSCX, MSCY, 5, 5);
Function MouseDistancePoint(Rx, Ry, Distance :integer) :boolean;
var
x, y :integer;
begin
Result := False;
GetMousePos(x, y);
if (x > Rx - Distance) and (x < Rx + Distance) then
if (y > Ry - Distance) and (y < Ry + Distance) then
Result := True;
end;
If they already exist sorry for creating this post, I just couldn't find them anywhere :/