How to approach game level switching

109 Views Asked by At

What is the best approach to switch to different scenes/areas in a 3D game from the render area?

Say you have a character and he moves into a new area, how would you go about unloading the area and loading the new area. Would you just load the render function up with different loading calls and only load them if they fell within certain parameters or would you create enumerators for each area and use something like a switch statement to switch to the new area after unloading your data for the current area?

I have always created REALLY bad transitions on small games I have made for a hobby and it usually kills my performance at some point or time.

1

There are 1 best solutions below

3
On

Using enum or/and switch/case is not very flexible.

You can simply use a function, example load_area(i), to unload a previous level/area then load level i instead (it could use a smart resource manager as suggested by Andon M. Coleman).

You should separate the resource handling from the game logic and the engine. Example, the rendering system should display currently loaded drawable resources rather than looping through enums and select which scene to render.

You should minimize the unloading/loading phases; depending on the game, you can completely avoid discrete transitions by using an LOD-like (level of detail) manager that updates resources dynamically depending on the current state of the game.