Suppose you have a 500x500 map with 10000 events scattered fairly uniformly throughout the map so that for any given tile, there are at most only a few events around you.
Suppose you are standing at (10, 10) and there is one event at (13, 13)
You then unleash a spell that affects all enemies within a square around the origin of the spell.
So for example if the size of the square is 5x5, then any events within the 25 tiles around the target position will be triggered.
What is an efficient way to check for this (with respect to the size of the square).
Basically, a naive solution would have it such that given a square of length n, the number of tiles to check is n^2.
How can this be improved?
Suppose you are standing at (10, 10) and there is one event at (13, 13)
You then unleash a spell that affects all enemies within a square around the origin of the spell.
So for example if the size of the square is 5x5, then any events within the 25 tiles around the target position will be triggered.
What is an efficient way to check for this (with respect to the size of the square).
Basically, a naive solution would have it such that given a square of length n, the number of tiles to check is n^2.
How can this be improved?
Last edited by a moderator:

