5
« on: June 22, 2012, 07:55:42 pm »
So, I'me building a 2D game engine and the main purpose is to create a top-down open-world shooter. Of course, open-world means lots of objects. So, I've searched in the foruns the best way to do this without decreasing performance a lot, however most of the topics were about SFML1 and Laurent stated that he wanted to change this stuff in SFML2. I've came to this conclusions, but I would like your opinion about them and more solutions, if you know any.
First, when loading the game the engine will compose a huge image with the objects that won't change during gameplay, like roads, buildings, etc... This can't be done when compiling because the maps will be dynamic.
Second, I'll try to render only stuff onscreen. I mean, if some object isn't visible, the engine won't even call the SFML draw function. I don't know if SFML handles this internally, so I'm not sure if this will make a big diference. The only problem about this is that I'm planning to use lights, and I'm not sure how to get over this problem. For example, if a light source is outside the screen, but close enough to get its light seen, it won't get rendered and that can be kind of akward. The only solution I see is to have a function for each kind of object that with it's given size and position determines if it is rendered or not.
Third, for not having to go through all the objects, I'll probably build some structure like a quad tree to make searching faster.
Fourth, I'll load objects as the player get's closer to them.
Thanks in advance,
Scorch