[epiar-devel] Infinite Canvas

Matthew Zweig thezweig at gmail.com
Mon Jan 18 22:16:39 PST 2010

After our discussion of the Navigation screen and the Infinite Canvas idea I started working on my own prototype.

You can check out my Infinity branch if you're curious.

As of now it's a fully functional Infinite Canvas.  The 'main' quadtree is centered at (0,0) and then quadtrees are created adjacent to that tree as needed.  Quads are created when a sprite moves into it and is destroyed when the last sprite leaves.  Right now, space is completely continuous, meaning that the Quads next to the center quad are centered at (2R,0) (-2R,0) (0,2R) and (0,-2R) where R is a #defined Quadrant size.

I think I've solved a few of the potential issues caused by having multiple QuadTrees at the same time.  Performance is comparable even when there are a lot of active Quads at the same time.  I don't think it's ready yet though, which is why I haven't pushed it to master.

There are a few architectural questions I need to figure out before I can proceed.

1)  Doubles and Floats lose precision as they get bigger.  The Pysics may work fine near (0,0) but might work really badly at (10E24,10E24).  I don't know how big we plan on making our universe, but I don't like the idea of things falling apart at the edges.  I would like to have each Quadrant maintain it's own Coordinate system. That way, the Coordinates never lose precision as you move between quadrants since you can't travel more than R before moving into the next Quadrant.  Unfortunately, I haven't figured out a good, clean way of doing this yet.  Another bonus to this idea is that we could define the planets as having solar and galactic coordinates rather than a pure galactic coordinates.  This would mean that we could change the size of a quadrant to adjust the distance between star systems but each solar system would remain coherent.  Also, coordinates like (-5000,5000) are much easier to think about and compare than (384200456,130783).

2)  How long do we need to keep track of Sprites?  If a ship is 10 quadrants away from the player, do we really need to run the full AI loop for that ship?  Alternatively, we need to keep the AI loops running for ships in nearby Quadrants so that the player can't just hop into the next quadrant for a while and then.  Could we just delete ships as they cross quadrant boundaries?  One idea would be to add a screen flash every time the player enters a quadrant, then delete all sprites in the old quadrant and create sprites in the new quadrant.  Also, how should ships be removed?  Simply blink them away?  Make them land on a planet?  Make sure ships are outside of the players' views before deleting them?

3)  How Should we handle creating more Ships?  Escape Velocity handled this by having ships warp in, but with an infinite canvas, they can only to be created at some point that is theoretically reachable by the player.  The current method is to create them occasionally around the planets as if they were launching off of that planet, but it still looks dirty.

Does anyone have any thoughts or suggestions?

~Matt Zweig

More information about the epiar-devel mailing list