Game Development Reference
In-Depth Information
5.8O PTIMIZATION O PPORTUNITIES
One thing many of our HUD elements share in common is the fact that many require iterat-
ing over the list of entities in the world and performing the same calculations, we calculate
the distance from each entity to the player, we compute the dot product, in some cases we
compute the relative angles. For our examples we iterate over the entities within each of our
elements, this gives us an algorithmic complexity of O( mn ) where m is the number of ele-
mentsthatrequireiteratingoverthelistofentities(locators,minimaps,radars,etc.).Wecan
createabaseclassforanyelementsthatrequireiteratingoverentitiesandinitwecancreate
a cache of visible entities, their distance relative to the player, relative angles and any other
information we may need during this game frame. This brings back the complexity to O( n )
for the iteration over the game entities.
Search WWH ::




Custom Search