Create Your first Project

In this tutorial, you will create your First Project. You will discover the Nero Dev-Engine and the Nero Scene Class. Then you will learn how both work together.

Create An Empty Project

Let’s begin slowly by creating a simple C++ project. Open the Engine folder and double click on the Launcher application, the CodeBlocks editor will open up. Click on Create a new project, then in the window that opens up choose Console application as shown in the video below. The project must be created inside the Engine Projects folder. The code generated is a simple C++ hello world program.

#include <iostream>
 
using namespace std;
 
int main()
{
    cout << “Hello world!” << endl;
    return 0;
}

The Nero Dev-Engine

Now that you have a basic project, let’s make the Nero Game Engine Editor also called Nero Dev-Engine appear. Like shown in the code below there are three steps. First, include the Dev-Engine header, then create an instance of the Engine and finally run the Engine. Replace all the previous code with the one below and compile your program. I encourage you to not copy and paste the code, you will learn and memorize faster by writing the code yourself.

//1-Include the Nero Dev-Engine header
#include <Nero/engine/DevEngine.h>
 
int main()
{
    //2-Create an instance of the Engine with a width of 1305 pixel
    nero::DevEngine engine(1305);
 
    //3-Let the Engine run
    engine.run();
 
    return 0;
}

Project Files & Folders

When the Engine starts the first time, it will create 5 Folders: Config, Log, Nero, Resource and Startup. Those folders must exist for the Engine to work properly, If you delete those folders the Engine will recreate them automatically. Let’s see what each folder is about.

  • Config
    This folder contains some Engine configuration files, you can change those configurations to adjust the Engine behavior.
  • Log
    This folder contains the Engine log files, most actions performed by the Engine are recorded in the logs files. This allows understanding what happened in case of a crash of the Engine.
  • Nero
    The Engine saves your game project here. This folder is very important, if you lose its content, you will lose all the work you have done.
  • Resource
    This folder stores the resources (images, fonts, animations, sounds, musics) used in your game.
  • Startup
    This folder also stores some resources, but only those used in the loading screen of your game.

As shown in the video below the Engine create or re-create those files automatically when it detects that they do not exist.

The Nero Scene Class

The Nero Scene Class is the base class of your game. To create a new game, you have to create a new class inheriting the class nero::Scene. Your new class will need a constructor with a nero::Scene::Context object as the only parameter. The context object provides a connection between your newly created class and the Engine. Through this object, the Engine gives you access to some useful features.

If you compile the code right now, nothing will happen. You have a new class for your game, but the Engine knows nothing about it.

//4-Include the Nero Scene Class header
#include <Nero/scene/Scene.h>
 
//5-Create a new Class called MyFirstGame,
//This new Class will customize the Nero Scene Class
class MyFirstGame : public nero::Scene
{
    public:
 
        //6-The constructor is mandatory
        //The Scene Context Object : this object is provided to you by the Engine,
        //It allows you to access some part of the Engine from your newly created Class
        MyFirstGame(nero::Scene::Context context): nero::Scene(context)
        {
 
        }
};
//1-Include the Nero Dev-Engine header
#include <Nero/engine/DevEngine.h>
//4-Include the Nero Scene Class header
#include <Nero/scene/Scene.h>
//5-Create a new Class called MyFirstGame,
//This new Class will customize the Nero Scene Class
class MyFirstGame : public nero::Scene
{
    public:
 
        //6-The constructor is mandatory
        //The Scene Context Object : this object is provided to you by the Engine,
        //It allows you to access some part of the Engine from your newly created Class
        MyFirstGame(nero::Scene::Context context): nero::Scene(context)
        {
 
        }
};
int main()
{
    //2-Create an instance of the Engine with a width of 1305 pixel
    nero::DevEngine engine(1305);
 
    //3-Let the Engine run
    engine.run();
 
    return 0;
}

Add A Scene To The Dev-Engine

For the Engine to know about your new Game Scene, you will have to provide it two things, the Name of your New Scene Class and the Name of your Game. This is done as shown below.

//7-Let the Engine now about your new awesome game
engine.addScene<MyFirstGame>(“my first game”);
 
//template
/*
    engine.addScene<Your New Class Here>(“the name of your game here”);
*/
//1-Include the Nero Dev-Engine header
#include <Nero/engine/DevEngine.h>
//4-Include the Nero Scene Class header
#include <Nero/scene/Scene.h>
//5-Create a new Class called MyFirstGame,
//This new Class will customize the Nero Scene Class
class MyFirstGame : public nero::Scene
{
    public:
 
        //6-The constructor is mandatory
        //The Scene Context Object : this object is provided to you by the Engine,
        //It allows you to access some part of the Engine from your newly created Class
        MyFirstGame(nero::Scene::Context context): nero::Scene(context)
        {
 
        }
};
int main()
{
    //2-Create an instance of the Engine with a width of 1305 pixel
    nero::DevEngine engine(1305);
    
    //7-Let the Engine now about your new awesome game
    engine.addScene<MyFirstGame>(“my first game”);
  
    //3-Let the Engine run
    engine.run();
 
    return 0;
}

Now that the Engine knows about your new game, If you compile your program, you will see that it is now possible to select “my first game” from the Scene selection button on the right. That’s it, you just finish creating your First Project.

The Nero Game Project Wizard

Now that you have created your First Project, you know the code to write each time you need to create a new project. It would be a bit annoying to write the same code every time, why not let the Codeblocks editor create the project for you? In the video below you can see how to use the Nero Game Project Wizard to create a new project.

Cpp Lessons

Do you know what a Namespace and a Forward Declaration are ? Learn that in the C++ Learn Section

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.