Tutorials » Scene » Setting up a Scene

A scene in the Untold Engine is composed of the MVC design pattern. It declares and defines the View, Model and Controller component for the current scene in a game. A game can have multiple scenes. For example, it can have a Start Scene, Level 1 Scene, etc. Again, for each scene, you must define the View, Model and Controller.

The process to set up a scene is simple. A scene is of type U4DEngine::U4DScene and upon initialization of a subclass, you must define the respective components. For example, the class snippet below declares the Menu view, logic and loading view.

#include "U4DScene.h"

#include "MenuView.h"
#include "MenuLogic.h"
#include "LoadingView.h"

class MenuScene:public U4DEngine::U4DScene {

private:
    
    //View class
    MenuView *menuView;
    
    //Game Model class
    MenuLogic *menuLogic;
    
    //View Class for a loading screen
    LoadingView *loadingView;
    
public:

    MenuScene();
    
    ~MenuScene();
    
    void init();
    
};

In the implementation of the subclass, the init() method defines the view, model and loading view for the whole scene.

void MenuScene::init(){
    
    //create view component
    menuView=new MenuView();
    
    //create model component
    menuLogic=new MenuLogic();
    
    //create loading view
    loadingWorld=new LoadingWorld();
    
    loadComponents(menuView,loadingView ,menuLogic);
    
}

It is not necessary to have a loading view if you don't want to. Upon execution of the init method, the engine will initialize the View, Model and Controller subclasses for your current scene and start the process mentioned above.