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/

https://en.wikipedia.org/wiki/quadtree


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -