0 Members and 3 Guests are viewing this topic.
I don't understand why you are constantly performing distance calculations each step if you only change the heading once every 500 ms.
This way you don't need to perform n^2 distance calculations.
May or may not help, but if you do a quick check to see if either the distance in the x or y dimension is greater than the minimum, then you don't need to use pythag to find the exact distance.
I don't know enough about the boids algorithm to know if it would be feasible and you might be doing this already, but unless you strictly need the actual distance between two boids, calculate the squared distance instead and sort based off of that. Calculating the square root is relatively expensive in terms of performance.
After seeing the swf in action, it appears that the framerate decreases the longer it is playing. I never got too far into the depths of programming, but from what I have picked up, wouldn't this indicate a memory leak?
Also some pointers if you want to go for a more 'traditional' flocking algorithm:
i would just like to say as a programming fresher that i think what you have coded is pretty awesome even despite the frame rate problem. nice work man you should be proud