Game Initialization

Understand what happens at the beginning of your Game

Scene Resolution

From the Engine Editor, when you click on the button Render, a new window opens up and you can preview the final version of your Game. You can configure the resolution of the preview’s window by using the Scene method virtual sf::Vector2f getSceneResolution(). The method simply returns a vector with the desired resolution.

 
sf::Vector2f MyScene::getSceneResolution()
{
	//let's use a resolution of 1280 x 720
	
    return sf::Vector2f(1280.f, 720.f);
}

The Method Init()

Do you want to start your Game with a Menu Screen or do you want the player to jump directly into the Game ? Which sound do you want to play when the Game starts ? There are many tasks and configurations to perform before the game starts playing, all of these are done inside the Scene method virtual void init(). The method is called just before the Game enters the Game Loop.

void MyScene::init()
{
    // do my stuff
}

Below you can see the init() method of the Adventure Scene Example. The following tasks are performed during the initialization of the game :

  • Configure the volume of Music and Sounds.
  • Setup the Scene Game Screens, which means choosing which Screens will be used, retrieve all buttons and setup their callbacks, choose which menu to start the Game with.
  • Setup Scene Collisions, which means deciding which categories of objects should collide together
  • Setup the Player, which means retrieve the player Game Object and link it to an  Action Object and link the player movement to the Camera
  • Adjust the Scene Settings
There are still many things that can be done inside the init() method, you will discover more when you get used to the Engine API.
void AdventureScene::init()
{
     /*
        --> This method lets you build the initial state of your Scene
        --> This method is called automatically when the Scene is rendered
        --> It's the Second method in your Scene to be called
    */

    log("Initializing Nero Adventure Scene v0.2");

    log("Setting up Sound and Music Volume ...");
    getSoundManager()->setSoundVolume(30.f);
    getSoundManager()->setMusicVolume(30.f);

    log("Setting up Scene Screens ...");
    setupSceneScreens();

    log("Setting up Collision rules ...");
    setupSceneCollisions();

    log("Setting up the Player ...");
    setupPlayer();

    log("Setting up the platform ...");
    setupPlatform();

    log("Setting up Scene settings ...");
    getSceneSetting().drawShapes = false;
    getSceneSetting().drawJoints = false;
}

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

Nero Games will use the information you provide on this form to be in touch with you and to provide updates and marketing.