As for game programming, I was just an amateur, but this is what I usually did:
I had an object, which was a very general concept of "Scenes" in the game. All major sections of the game derived from this scene object. A scene can really be anything, depending on the type of game. In any case, each more specific scene obtained from the scene had a procedure for loading all the necessary elements for this scene.
When the game consisted of changing scenes, the pointer to the active scene was set to a new scene, which then loaded all the objects it needed.
The shared Scene object had virtual functions, such as Load, Draw, and Logic, which were called at a specific time in the game loop from the active scene pointer. Each particular scene had its own ways of implementing these methods.
I do not know how this should be done or not, but it was very easy for me to control the flow of things. The concept of the scene also simplified the storage of several scenes as collections. With several pointers to the scene stored in the stack once a time, the scenes can be stored in reserve and maintain their full state upon return, or even do something like a dull one, but continue to draw while the active scene has drawn them as an overlay of views.
One way or another, if you do it this way, it is not as accurate as a web page, but I think if you think about it correctly, it will be quite similar.
Gene roberts
source share