What is the best way to render a 2d game map?
- by Deukalion
I know efficiency is key in game programming and I've had some experiences with rendering a "map" earlier but probably not in the best of ways.
For a 2D TopDown game: (simply render the textures/tiles of the world, nothing else)
Say, you have a map of 1000x1000 (tiles or whatever). If the tile isn't in the view of the camera, it shouldn't be rendered - it's that simple. No need to render a tile that won't be seen. But since you have 1000x1000 objects in your map, or perhaps less you probably don't want to loop through all 1000*1000 tiles just to see if they're suppose to be rendered or not.
Question: What is the best way to implement this efficiency? So that it "quickly/quicker" can determine what tiles are suppose to be rendered?
Also, I'm not building my game around tiles rendered with a SpriteBatch so there's no rectangles, the shapes can be different sizes and have multiple points, say a curved object of 10 points and a texture inside that shape;
Question: How do you determine if this kind of objects is "inside" the View of the camera?
It's easy with a 48x48 rectangle, just see if it X+Width or Y+Height is in the view of the camera. Different with multiple points.
Simply put, how to manage the code and the data efficiently to not having to run through/loop through a million of objects at the same time.