I've basically been following the coding train example from youtube but i am getting single digit frame rates. Pretty sure i am doing something stupid rather than this being a hardware limitation. Any help would be great! You can see my attempt here:

youtube vid for reference:

  • an update on this for anyone looking into this in the future. It was indeed the naive approach for checking every other circle which was the problem. I implemented a Spatial Hash Grid so that each circle is only checking for other circles within a certain distance. Can easily have 3x the previous number of circles on screen without any dip in framerate.

duane Your pasted code isn't visible. You might have to paste into your post with ~~~.

That's not the issue, pastebins should auto embed here, it's just that the pastebin has expired.

    Megalomaniak duane thanks - not sure why it expired, sorry about that. Updated it with a new one.

    I've played around with it a bit more and looked at various performance metrics in the debugger. I think the issue is how inefficient the logic for detecting overlap is inside the _draw() function since every circle needs to check every other circle before it expands which i think makes its O(n2). Even without the update() to refresh the screen, the latency in _process() is spiking like crazy when the number of circles goes above 300.

    Not sure how P5.js and Processing handles this so well in that video... but I'm going to try implementing a quadtree later today to see if this will help. I'm pretty new to Godot / coding so just making this up as I go! Any other ideas would be appreciated!

    an update on this for anyone looking into this in the future. It was indeed the naive approach for checking every other circle which was the problem. I implemented a Spatial Hash Grid so that each circle is only checking for other circles within a certain distance. Can easily have 3x the previous number of circles on screen without any dip in framerate.

    Great, clad to hear it! And thanks for sharing the solution so others can have a hint too. 🙂