Say I have a bunch of objects scattered around a map. This is a tile-based, scrollable,
zoomable map. I want objects in the camera's view to be drawn and objects off the screen
to be ignored, naturally. (Objects are z-sorted, then drawn on top of the tiles in a seperate loop.)
How would you guys go about this?
I can think of 2 methods offhand.
1. Cycle through each object on the map and use an If-statement to check if it's
visible. (Very amature, and with thousands of objects, it's very slow)
2. Attach each object to a ground tile, so that the same code that draws the ground tiles
automatically knows when to draw in any visible objects. (Used with good results in the
past. It's limited though, you don't have the freedom to bunch too many objects together,
and the object cannot stray too far from its home tile, or else it disappears along with the
tile before it's off the edge of the map.)
What methods do you guys use?
zoomable map. I want objects in the camera's view to be drawn and objects off the screen
to be ignored, naturally. (Objects are z-sorted, then drawn on top of the tiles in a seperate loop.)
How would you guys go about this?
I can think of 2 methods offhand.
1. Cycle through each object on the map and use an If-statement to check if it's
visible. (Very amature, and with thousands of objects, it's very slow)
2. Attach each object to a ground tile, so that the same code that draws the ground tiles
automatically knows when to draw in any visible objects. (Used with good results in the
past. It's limited though, you don't have the freedom to bunch too many objects together,
and the object cannot stray too far from its home tile, or else it disappears along with the
tile before it's off the edge of the map.)
What methods do you guys use?