From: Chad \Exodist Admin-Ra\ Granum <granum@sb...> - 2004-12-29 06:12:03
Note: sections relevant to developers, documentation managers, and all
hand men below:
To Documentation Managers:
Please add information regarding how we find objects within range as
explained below to the appropreate document. please correct spelling and
grammer as usual, seems mine may have further declined do to my current
FYI since you wanted to work on path AI and such I have added a meathod
to the MapHash object where it will return a linked list of all objects
on the map within a radius froma center point:
LinkedList somelist = SomeMapHash.get(10, 10, 20);
will return every object on the map within 20 grid units from the grid
unit X:10 Y:10
so if you give it the center coordinates of the character you are using
(characters x and y + 1/2 the size of th echaracter on that axis) as
well as it's sight distance it will retunr all of the enimies within
your viewing distance, useful for monsters that seek players to kill.
It returns everything in a rough circular radius, not a square one so
you do not need to do any additional filtering for distance after
obtaining the list.
To developers and All hands men:
I used the pathagorean therom.. I think that is what it is called anyway
where a^2+b^2=c^2 C being the longer of the 3 edges of a triangle to
it takes the difference on each axis between the given center point and
the object it checks then calcs the distance using the x and y diffs as
A and B, then it checks C against the radius value given. to make it
simple I just casted it as an int, I figure we do not need decimal
precision in this case.
If anyone knows of a better way, or can improve/check my math inside the
meathod (MapHash.get(int, int, int,)) and (MapHash.pathagDistance(int,
int)) please let me know.
-Chad "Exodist" Granum
Get latest updates about Open Source Projects, Conferences and News.