SRL Archive - Reflection Development

function inbox(Tilex1, Tiley1, Tilex2, Tiley2: integer): Boolean;


Shady?

2008-09-14 01:40:04

Well, i just made this, it checks if we are inside a certain box of tiles, where the first X and Y are the top left ones, and the second are the down right corner.

function InBox(Tilex1, Tiley1, Tilex2, Tiley2: integer): Boolean;
var
Path, pat: TPointArray;
MyX, MyY, X, Y: Integer;
i, p: integer;
begin
i := 0;
p := 1;
if not LoggedIn then exit;
SetLength(Path, 1);
SetLength(Pat, 1);
Path[i] := GetMyPos;
if Path[i].X >= Tilex1 then
begin
if Path[i].Y <= Tiley1 then
begin
if Path[i].X <= Tilex2 then
begin
if Path[i].Y >= Tiley2 then
begin
Result := true;
end;
end;
end;
end;
end;

Example:

if (Inbox(3208, 9622, 3219, 9615)) then
begin
Writeln('We are inside the box!');
end;

turbobk

2008-09-14 08:11:05


Function InTheBox(x1, x2, y1, y2: Integer): Boolean;
Var
P: TPoint;
Begin
P := GetMyPos;
Result := PointInBox(P, IntToBox(x1, x2, y1, y2));
End;

Or..


Function InTheBox(Box: TBox): Boolean;
Var
P: TPoint;
Begin
P := GetMyPos;
Result := PointInBox(P, Box);
End;

:rolleyes:

Drakan

2008-09-14 08:37:21

or….
TileInBox and MeInBox are both in my include…

EDIT:
And I believe there is already PointInBox…

Nava2

2008-09-14 09:31:33

Or

PointInBox(Tile, xs, ys, xe, ye);

Shady?

2008-09-14 12:04:25

or

 This := Fail 

turbobk

2008-09-16 07:26:43

No this is not a fail, it is very good.
It's just that there is a faster / simpler way to do it.

The[Cheese] & Nava2, if you looked at my function, I used 'PointInBox'.
Also Nava2,

PointInBox(Point: TPoint; Box: TBox): Boolean;

It use's a TBox not xs, ys, xe, ye. :p

Widget

2008-09-16 19:25:32

PointInBox(GetMyPos, IntToBox(x1, y1, x2, y2));

Anything extra is a waste of space :p