Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There's a couple of different strategies. Honestly, 2500 objects to inspect is "a lot", but in reality it's not that much and this is the sort of thing that can be optimized to the n-th degree. Often the bottleneck is in the draw calls themselves, not iterating over the objects.</p> <p>So, iterate over the objects and do a frustum check. That is, test if the objects are entirely outside of the player's view. Don't draw if they are. If you're only drawing in 2D this is often straightforward. If it's 3D then you'll need some more advanced mathematics but nonetheless still straightforward linear algebra.</p> <p>The next generic method a step up from this is some sort of scene graph or otherwise spatial structure. This becomes a whole lot more complex very quickly, but it performs well with any 2D/3D content at any angle at any time. (Google is your friend for now, the question is very open-ended.)</p> <p>Alternatively, if you've got a simple 2D top-down view of the squares you could create a simple 2D array and draw the parts of the map that are relevant based on the camera coordinates. (Do a linear transformation on camera coordinates X and Y that scales down into array indices and then draw a rectangle of array coordinates.)</p> <p>I wouldn't typically recommend a differential approach unless there's some very special reasons for it. It's usually hard to manage and useless when you jump locations.</p> <p>The sky is the limit without knowing some more details, but try to keep it simple. Making games is hard enough.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload