algorithm - Efficiently determine which units are in the range of AOE spells in RPG games, like World of Warcraft and dota 2? -
as aoe, area of effect, circle, first thought came calculate distance between each unit in map center of circle, , determine unit in range of circle formula (xunit - xcenter)2 + (yunit - ycenter)2 < r 2 , r radius of circle.
apparently, not efficient algorithm. maybe can improved downsizing calculating area first, , use formula above. calculations still time consuming operations, , hashing may efficient way solve problem while don't know how :( . , wonder algorithms used in games.
these might help:
collision detection, bounding circle http://mastrgamr.net/xna/xna-collision-detection-bounding-circle/
bounding box collision detection http://www.dreamincode.net/forums/topic/180069-xna-2d-bounding-box-collision-detection/
Comments
Post a Comment