No, iterating over the entire list every update is not the most efficient way to solve the problem when not every entity needs to be updated every frame, but it will probably not cause you any performance issues in a simple game. This especially applies if you add a flag to each entity and any that do not need to be updated constantly could be ignored based on the status of the flag.
However, if it bothers you, you can keep a list of all entities, and then a separate list of entities that are currently relevant and update only those. If you look at each entity as a task in a system, then your game simulation becomes a kernel and you could manage tasks similarly. I'm not going to get into that here because task scheduling is huge and there's no one right way to do it.
Show differencesHistory of post edits
#1smr
Posted 13 March 2012 - 09:54 AM
No, iterating over the entire list every update is not the most efficient way to solve the problem when not every entity needs to be updated every frame, but it will probably not cause you any performance issues in a simple game. This especially applies if you add a flag to each entity and any that do not need to be updated constantly could be ignored based on the status of the flag.
However, if it bothers you, you can keep a list of all entities, and then a separate list of entities that are currently relevant and update only those. If you look at each entity as a task in a system, then your game simulation becomes a kernel and you could manage tasks similarly. I'm not going to get into that here because scheduling is huge and there's no one right way to do it.
However, if it bothers you, you can keep a list of all entities, and then a separate list of entities that are currently relevant and update only those. If you look at each entity as a task in a system, then your game simulation becomes a kernel and you could manage tasks similarly. I'm not going to get into that here because scheduling is huge and there's no one right way to do it.