In my understand, the logic of sprite would be separated into 2 levels.
Bottom level is the moving behavior or other appearance behaviors, to set the position/angle/opacity/... of this sprite. This level would export some commands like turn left/turn right/accelerate/brake for top level.
Top level is the controller, it would fire these commands by human input, or fire by logic (NPC/AI). This AI logic might be
- Code: Select all
if ( some_conditions )
Boids and LJ potential would provide some values for condition checking, They would not set properties (position/angle) of this sprite directly.
Back to "collision avoidance behavior", it might be another kind of moving behavior since it needs set the position directly to become "collision avoidance". So it would be another behavior.
In above boids demo, sprite would try not too closed to the obstacles by some logic, but it might not "collision avoidance" for all cases without adjust any term of the controller logic.