A few days ago, I posted an incredibly early prototype of a green dot able to “move around” a red dot, even though the green dot always stayed put in the middle of the screen.
After the sheer amount of code effort to even get that far, I can feel the pull of a grid beckoning me to go back to it, because everything is so much easier.
I am resisting, but it is difficult.
There is so much more to manage once we leave our safe compartmentalized gridworld.
Collisions become far more complex. I now have to check against everything in my general area for collisions.
And the whole “in my general area” question is rather large, too.
I obviously have to subdivide my world into manageable regions/zones/chunks, but how to do it? Quadtree? Region entities within the World?
Here’s my rough not tried yet plan:
Divide the world into regions. Regions are, at scale 1:1, one half of the width and height of the screen. When rendering, I only need to render chunks +/- 1 from my chunk XY location.
In this way, I generally only have to concern myself with the denizens of the particular chunk that I’m in when checking for collisions.
Unless I’m near the edge, in which case I have to also check for neighboring chunks as well.
Of course, now I have to manage movement between chunks. Fortunately, since things are circles, when the center is in a different chunk, move to that chunk.
Also, for things that have an ai or behavior of some kind, only go a particular number of chunks in any direction to calculate those things. Now I’ve got infinite world and finite computational time.
Or do I just learn to use quad trees and be done with it?