Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Sk Landry

Pages: 1 2 [3] 4 5 6
31
SFML projects / Re: Nero Game Engine
« on: April 29, 2018, 04:51:27 pm »
How to code with the engine Part 1-7 : Build a simple player

Hi everyone, hope you are doing great. Let's continue with the series.

In this post I will show how to use an ActionObject and some Actions in order the build a simple player

Step 0 : Include the Nero GameLib header

#include <NERO/gamelib.h>

Step 1 : Create the player object

The first step is to create the object that will be your player using the Dev_Engine_Interface. For this example we can take a simple cube or circle to be the player. So let's create a Physic_Object (Polygon Mesh) with the name "my_player" and the category "player"

step 2 : Use an ActionOject to represent the Player

nero::PhysicActionObject my_Player;
my_Player.setObject(m_ObjectManager.findObject("my_player"));

In the Howto on Moving Objects and Platforms, we used a Custom PhysicActionObject called SimpleMovingObject. The SimpleMovingObject inherit from PhysicActionObject in order to build a more complex interface. But as you can see the default interface of the PhysicActionObject is enough for certain cases. There are many ways to use ActionObject and Action, and for this tutorial we are using the most basic one.

step 3 : Give the player defferent capabilities

Let's say we want our player to be able to move right and left. we also want it to be able to jump.

float move_velocity = 100.f
float jump_force   = 150.f

my_Player.registerAction<MoveAction>("move_left", nero::getMoveLeftAction(move_velocity));
my_Player.registerAction<MoveAction>("move_right", nero::getMoveRightAction(move_velocity));
my_PLayer.registerAction<JumpAction>("jump", nero::getJumpAction(jump_force));

In the code above we've registered three Actions, the player can then perform those actions when ever it want.

void handleKeyboardInput(const sf::Keyboard::Key& key, const bool& isPressed)
{
    if(isPressed)  
    {
       switch(key)
       {
       case sf::Keyboard::J:
           {
               my_PLayer.callAction("jump");
           }break;
       }
       
   }  
}

If you want to see how Actions are built, click on the spoiler button.
(click to show/hide)

Step 4 : Make the camera follow your player

The nero::Scene offers a method called setCameratTarget, that you can used to make the camera follow any Physic_Object.

auto player_object    = m_ObjectManager.findObject("my_player"); //retrieve the object to follow
auto target       = nero::PhysicObject::Cast(player_object); // cast the object to a Physic_Object

setCameraTarget(target); // set the target

It's possible to disable and enable this feature at any moment with the following method

setCameraFollowTarget(bool flag);


This post showed how ActionObject and Action could be used to create a simple player, for a complet example you can check the code in the Kero project.

32
SFML projects / Re: Nero Game Engine
« on: April 16, 2018, 09:17:38 pm »
How to code with the Engine Part 1-6 : Handle Collisions

Hi everyone, hope you are doing great. Let's continue this series with Collisons processing

1- Setup the collision rules

Let's consider the following Object Categories (ground, platform, cirlce, cube) and the following rules
  • circles and cubes can collide with ground
  • only circles can collide with platforms
  • circles cannot collide with circles
  • cubes can collide with cubes
  • circles and cubes cannot collide
using a nero::CollisionRule object you can configure this setup with the code bellow

nero::CollisionRule collisionRule;
           
collisionRule.canCollide("circle", "ground");
collisionRule.canCollide("cube", "ground");
collisionRule.canCollide("circle", "platform");
collisionRule.canCollide("cube", "cube");

collisionRule.apply(m_RootObject);

When the apply() method is called, the collisionRule object first remove all previous collision configuration by calling the noCollision() method. When this method is called, no object can collide with any other object, this is why you only have to tell which Category should collide with which one when setting up the rules.

2- Print the collision rule

if you want to see the collision rules in a more readable way, you can called the print() method

collisionRule.print();

3- Process collisions

when a collision occur, the handleCollisionContactBegin() method is called first. The collision is represented as a nero::Collision Object

void handleCollisionContactBegin(nero::Collision collision)
{
    if(collision.isCollising("ground", "cube"))
    {
        nero_log("ground-cube collision detected");

        auto object_1 = collision.getObject("ground");
        auto object_2 = collision.getObject("cube");

        nero_log(_sn(object_1));
        nero_log(_sn(object_2));
    }

    if(collision.isObjectCollising("platform_1", "circle_1"))
    {
        nero_log("platform_1 and circle_1 just collided");

        auto object_1 = collision.getObject("platform_1");
        auto object_2 = collision.getObject("circle_1");

        nero_log(_sn(object_1));
        nero_log(_sn(object_2));
    }
}

4- Test collisions

The collision object offer two methods to test collisions by category or by name

collision.isCollising("object_category_1", "object_category_2");

collision.isObjectCollising("object_name_1", "object_name_2");

The test with a category and a name is not availabled, I will had that for a future release.

5- Retrieve the colliding objects

You can use the getObject() method to retrieve the objects that are colliding, the method takes a category or a name as parameter. The returned object is a nero::PhysicObject

PhysicObject::Ptr collision.getObject(sf::String indicator)

//Example
auto object = collision.getObject("object_category");
//or
auto object = collision.getObject("object_name");


5- Disable collisions

A collision can be easly disabled with the code bellow

collision.setEnabled(false);

6- A full example

You can create the Scene for this example, with this  following json file.

download the scene json

#include <NERO/engine/DevEngine.h>
#include <NERO/scene/CollisionRule.h>

class MyScene : public nero::Scene
{
    public:
        MyScene(nero::Scene::Context context):
            nero::Scene(context)
        {

        }

        void init()
        {
           m_ObjectManager.checkAllObject(
            {
                "platform_1",
                "circle_1",
            });

            nero_log("The collision rules");

            nero::CollisionRule collisionRule;

            collisionRule.canCollide("circle", "ground");
            collisionRule.canCollide("cube", "ground");
            collisionRule.canCollide("circle", "platform");
            collisionRule.canCollide("cube", "cube");

            collisionRule.apply(m_RootObject);

            collisionRule.print();
        }

        void handleCollisionContactBegin(nero::Collision collision)
        {
            //this method is called first when a collision occur;

            if(collision.isCollising("ground", "cube"))
            {
                nero_log("ground-cube collision detected");

                auto object_1 = collision.getObject("ground");
                auto object_2 = collision.getObject("cube");

                //nero_log(_sn(object_1));
                //nero_log(_sn(object_2));
            }

            if(collision.isObjectCollising("platform_1", "circle_1"))
            {
                nero_log("platform_1 and circle_1 just collided");

                auto object_1 = collision.getObject("platform_1");
                auto object_2 = collision.getObject("circle_1");

                //nero_log(_sn(object_1));
                //nero_log(_sn(object_2));
            }


            //If I disabled the collision here, the method (handleCollisionContactEnd) will never be called
            //collision.setEnabled(false);
        }


        void handleCollisionContactEnd(nero::Collision collision)
        {
            //this method is your last change to process a collision
        }
};

int main()
{
    nero::DevEngine engine;
    engine.addScene<MyScene>("My Scene");
    engine.run();
}
 




33
SFML projects / Re: Nero Game Engine
« on: April 14, 2018, 03:40:45 pm »
How to code with the Engine Part 1-5 :  Create Moving Objects and Platforms

Hi everyone! how are you doing :). I've been busy the last weeks so I couldn't pursue the series, but here I am.
In this post I'll present a custom PhysicActionObject called SimpleMovingObject. This ActionObject can be used to create moving platorm or to make move any PhysicObject.

There is little change in the schedule, the HowTo on the Player will come after the one on Collision. That said, let's begin.

1- Include the NERO\gamelib.h header

#include <NERO/gamelib.h>

The Nero Game Lib library  defined some custom Actions and ActionObjects. This library is not part of The Engine Core, currently it is provided as a header only library. You can find it in the package in : Library\gamelib\NERO\gamelib.h
Further in the tutorial I will show How to create custom Actions and ActionObjects. For now let's use the ones provided in the gamelib library.

2- SimpleMovingObject, the constructor

nero::SimpleMovingObject(direction, velocity, maxOne, maxTwo);

direction    : [right_left , up_down]    // the direction of the movement
velocity     : [float]                   // the speed of the movement
maxOne       : [float]            // the distance to cover in the first direction (right or up)
maxTwo       : [float]            // the distance to cover in the second direction (left or down)

3- Example

nero::SimpleMovingObject(nero::SimpleMovingObject::Right_Left, 20.f, 100.f, 150.f)

//In the following example, the targeted object will move right and left at a speed of 20 float;
//The object will first move 100 float to the right, then it will come back to its initial position before
//to move 150 float to the left. the total distance of the movement it's therefore 350 float

4- A little trick

If you want the object to move Left_Right, instead of Right_Left, just set maxOne to Zero (0.f)

nero::SimpleMovingObject(nero::SimpleMovingObject::Right_Left, 20.f, 0.f, 250.f)

//Since the object should move 0 float to the right before to go left,
//the object will go left first, what's give you a left_right movement. this work also for the up_down movement.

5- Add the SimpleMovingObject to the Object Tree

The role of an ActionObject is to provide a behavior to another Object (the Target). As we want our ActionObject to have full control of the target, we will first remove the target from the Object Tree, and then give it to the ActionObject. Only after that we can add the ActionObject to the Object Tree

We create the ActionObject as a Pointer since it will be added to the Object_Tree

nero::SimpleMovingObject::Ptr my_Platform;
my_Platform(new nero::SimpleMovingObject(nero::SimpleMovingObject::Right_Left, 20.f, 0.f, 250.f));

We remove the Target from the Object Tree and give it to the ActionObject.
the Object_Manager MoveObject method, cut the target from the Tree and return it

auto target = m_ObjectManager.moveObject("my_platform");
my_Platform->setObject(target);

The Object_Manager will add the ActionObject to the Object Tree

m_ObjectManager.addObject(my_Platform);

6- Some reminders

The SimpleMovingObject is a PhysicActionObject, currently it's the only ActionObject in the gamelib library. As a PhysicActionObject, it handles only PhysicObjects (SolidObjects are also PhysicObjects).

This ActionObject should be used on Kinematic PhysicObject.

Static Objects are not meant to move and Dynamic Objects are meant to be affected by a lot of things (gravity, collisions) what is not ideal for this ActionObject.

7- A full example

First create a Kinematic PhysicObject (Kinematic Mesh) named "my_platform" before to run this code

#include <NERO/engine/DevEngine.h>
#include <NERO/gamelib.h>

class MyScene : public nero::Scene
{
    public:
        MyScene(nero::Scene::Context context):
         nero::Scene(context)
         ,my_Platform(new nero::SimpleMovingObject(nero::SimpleMovingObject::Right_Left, 50.f, 100.f, 100.f))

        {

        }

        void init()
        {
            //First create a Kinematic PhysicObject (Kinematic Mesh) before to run this code

            m_ObjectManager.checkAllObject(
            {
                "my_platform",
            });

            auto target = m_ObjectManager.moveObject("my_platform");
            my_Platform->setObject(target);

            m_ObjectManager.addObject(my_Platform);

        }

        nero::SimpleMovingObject::Ptr my_Platform;
};

int main()
{
    nero::DevEngine engine;
    engine.addScene<MyScene>("My Scene");
    engine.run();
}


34
SFML projects / Re: Nero Game Engine
« on: March 26, 2018, 11:54:10 pm »
How to code with the Engine Part 1-4 :  Retrieve objects

1- Find Objects

The findObject() method, run other the whole Object_Tree_Node to find an Object. This may be resource and time consuming if your Scene contains too many Objects. You can optimize the research if you know the nature of the Object you are looking up for.

If the Object is a Physic_Object by example, use the findPhysicObject() method, This method will skip all layer that does not contain Physic Objects during its look up process.

There are a list of methods you can use to retrieve Object more efficiently
Object::Ptr     findObject(sf::String name);
Object::Ptr     findLayerObject(sf::String layer_name);
Object::Ptr     findObjectInLayer(sf::String name, sf::String layer_name);
Object::Ptr     findSpriteObject(sf::String name);
Object::Ptr     findPhysicObject(sf::String name);
Object::Ptr     findSolidObject(sf::String name);
 

2- Move Objects

The Move methods, cut the Objects you are looking up for from the Object_Tree_Node. So you can re-attach them somewhere else in the Tree.

Object::Ptr     moveObject(sf::String name);
Object::Ptr     movePhysicObject(sf::String name);
Object::Ptr     moveSpriteObject(sf::String name);
Object::Ptr     moveSolidObject(sf::String name);
 

3- Remove Objects

The Remove methods, will destroy complety an object. If the Remove methods do not find the object you want to remove they return false

bool            removeObject(Object::Ptr object);
bool            removeObject(sf::String name);
 

4- Objects Casting

The Find and Move methods always return a generic nero::Object, if you want to perform object specific tasks, you will have to cast the returned Object first. All Object Type have a static Cast() method for that.

nero::Object::Cast()
nero::LayerObject::Cast()
nero::SpriteObject::Cast()
nero::PhysicObject::Cast()
 

Example
auto my_cloud_sprite    = m_ObjectManager.findObject("cloud_sprite");
auto my_ground          = m_ObjectManager.findObject("ground_01");

nero::SpriteObject::Ptr sprite_object = nero::SptriteObject::Cast(my_cloud_sprite);
nero::PhysicObject::Ptr physic_object = nero::PhysicObject::Cast(my_ground);
 

A Solid_Object is a Physic_Object with a Sprite_Object as a child. So a Solid_Object is casted to a Physic_Object

auto object = m_ObjectManager.findSolidObject("object_name");

nero::PhysicObject::Ptr physic_object = nero::PhysicObject::Cast(object);
nero::SpriteObject::Ptr sprite_object = nero::SptriteObject::Cast(object->getFirstChild());
 

35
SFML projects / Re: Nero Game Engine
« on: March 26, 2018, 11:21:18 pm »
How to code with the Engine Part 1-3 :  Check Objects

Any Object can be retrieved at any moment with a  [ m_ObjectManager.findObject("object_name") ] . The thing to know is that the Object_Manager return a Null_Ptr when it does not found a Object. The reasons the Object_Manager does not found a object may be because the Object simply does not exist, may be you misspelled the Object_Name, or you simply forget to assign the name with the Dev_Engine Interface. So in principle you should test any returned object before to use it like that.

auto object = m_ObjectManager.findObject("oject_name")
if(object)
{
        //do something
}

This is pretty combersome. In order to reduce the risk of using unexisting Objects, you can check them all at the beginning of the init() method.
the method [ m_ObjectManger.checkAllObject(std::vector<sf::String>) ] is there for that. you can give it all the Object_Names you will be using. If it found that a object does not exist, it throws a exception and give you the culprit, I means the Object_Name, that refer to nothing.

void init()
{
    //Test that all objects exist before to continue
    m_ObjectManager.checkAllObject(
    {
        NamePool.start_ground,
        NamePool.jump_power,
        NamePool.player,
        NamePool.start_platform,
        NamePool.start_end,
    });


    // Everything fine here, we can continue safely

}

36
SFML projects / Re: Nero Game Engine
« on: March 26, 2018, 11:06:59 pm »
How to code with the Engine Part 1-2 :  Use constants

The Engine use a lot of Strings to do its stuffs. Objects in a Scene are identified by they Name and they Category. The Names and Categories are used everywhere and many time in the code, writting them every time is error prone, so as a good practice, this Strings should be declared as constants and maintained in one place. Also notice that Names and Categories should be unique.

As an example the kero project defined several constants in the Kero_utility.h file like this.

struct _NamePool
{
    const sf::String start_ground       = "start_ground";
    const sf::String player             = "kero";
    const sf::String jump_power         = "jump_power";
    const sf::String start_platform     = "start_platform";
    const sf::String start_end          = "start_end";

};

struct _CategoryPool
{
    const sf::String ground             = "ground";
    const sf::String wall               = "wall";
    const sf::String player             = "player";
    const sf::String power              = "power";
    const sf::String platform           = "platform";
};

struct _PlayerActionPool
{
    const sf::String move_left         = "move_left";
    const sf::String move_right        = "move_right";
    const sf::String move_none         = "move_none";
    const sf::String jump              = "jump";
    const sf::String dash_left         = "dash_left";
    const sf::String dash_right        = "dash_right";
};

const _NamePool             NamePool;
const _CategoryPool         CategoryPool;
const _PlayerActionPool     PlayerActionPool;
 

37
SFML projects / Re: Nero Game Engine
« on: March 26, 2018, 10:56:50 pm »
How to code with the Engine Part 1-1 : The nero logger

Log things is pretty useful when programming, this is why I wanted to start this series of Howtos with the logger.
The Engine use the Easyloggingcpp library for logging. the default synthax look like this 
[ LOG(INFO) << "log message here, this goes to the console" ]
If you ever used that library and are familiar with it, you can still use its default synthax.

I prefer function-like synthax, this is why I design the [ nero_log() ] and [ nero_log_if() ] functions to replace the original synthax. Those functions are in fact Macros, this is why they don't use the nero namepsace.

Here is a overview of these two functions
nero_log(message)
nero_log(message, level)
nero_log_if(message, boolean)
nero_log_if(message, boolean, level)
 

Two levels are availabled. Not specifing a level is equivalent to use the logger in INFO level
nero::Debug
nero::Warning

//The Debug and Warning level will give the File, the Line and the Method where the log has been called
[DEBUG | main.cpp | Line 21 | virtual void MyScene::init() ] --> Hello world
 

In addition to the logger Macros, you also got some toString Macros
_s(value)        
//equivalent to nero::toString(value), it automatically add a space at the end.

_sn(object)    
 //call the toString method of the object, equtivalent to object->toString()
 

Things  are always more easy with examples, so here are some
x = 5;
auto myPlayer = m_ObjectManager.findObject("player");

nero_log("whatever");
nero_log("whatever", nero::Warning);
nero_log_if("whatever", x < 10);
nero_log_if("whatever", x > 0, nero::Debug);
nero_log("step : " + _s(10) + "the winner is : " + _sn(myPlayer), nero::Debug);
 

38
SFML projects / Re: Nero Game Engine
« on: March 24, 2018, 09:15:38 am »
How to code with the Engine Series

Hi everyone, after the 101 (see the above post), we can now move further and see how to code with the engine.

As I made with the DevEngine Interface, I will made a series of posts to show how to develop a Game with the Engine.

In the Engine Kit there is the project Kero. this project is my game prototype, more exactly the quater of it. I design the prototype in four parts. You can take a look at the code to see how it works. The 3 others parts of the prototype will be part of this tutorial.

bellow you can see the outline of this new series of posts

Part 1: Let's begin slowly

   1/ The nero logger
   2/ Use constants
   3/ Check Objects
   4/ Retrieve objects
   5/ Create a simple Player
   6/ Create a moving platform
   7/ Handle Collisions
   8/ Analyse of the Kero Scene code

Part 2 : Let's finish that Prototype

   1/ the Second part
   2/ The Third part
   3/ The Last part

39
SFML projects / Re: Nero Game Engine
« on: March 24, 2018, 08:48:19 am »
Developing Games with the Engine 101

Hi everyone how are you doing :), In this post we'll see how to start programming with the Engine

1- Create a new Scene

In order to create a new Scene, you simply have to create a new Class inherating from nero::Scene. After that you can add  your scene to the Engine with the method [ addScene<Scene_Class>("scene_name") ]. you can add any number of Scenes.

Pay attention to the scene name, the name will be used to generate a directory for your scene, So the characters you can enter there depends on your Operating System rules in term of Folder and File Name.

The Engine Instantiate your Scene each time you click on the Play_Button.

#include <NERO/engine/DevEngine.h>

class MyScene : public nero::Scene
{
    public:
        MyScene(nero::Scene::Context context):
            nero::Scene(context)
        {
            nero_log("Hello bodies");
        }
};

int main()
{
    nero_log("Nero Game Engine Hello World");

    nero::DevEngine engine;
    engine.addScene<MyScene>("My Scene");
    engine.run();
}
 

2- The init() method

The init() method is called automaticlly after the constructor of your Scene, This method exist in order to allow doing stuff that can't be done in the construstor. It's in this method that you can retrieve objects, preconfigure your player, your scene logic etc.

Using the Dev_Engine Interface, first create an Object named "test" before to run the bellow code.

#include <NERO/engine/DevEngine.h>

class MyScene : public nero::Scene
{
    public:
        MyScene(nero::Scene::Context context):
            nero::Scene(context)
        {
            nero_log("Hello bodies");
        }

        void init()
        {
            nero_log("the init() method is called automatically after the constructor");

            //Create a mesh object and give it the name "test" before to run this code
                auto object = m_ObjectManager.findObject("test");

                nero_log(_sn(object));

            // the little "_sn" is a toString method; the "s" is for String, the "n" is for Nero Object
        }
};

int main()
{
    nero_log("Nero Game Engine Hello World");

    nero::DevEngine engine;
    engine.addScene<MyScene>("My Scene");
    engine.run();
}
 

3- Run the Render_Engine

In order to launch the Render_Engine, simply replace the DevEngine header by the RenderEngine one [ #include <NERO/engine/RenderEngine.h> ], and then change the code in the main like bellow.

The Render_Engine takes only one Scene, so it use the method [ setScene<Scene_Calss>("scene_name") ]

The Render_Engine run a 800 x 600 window by default, you can change that by modifying its constructor like that
[ nero::RenderEngine engine("default name", 1024.f, 600.f) ]

#include <NERO/engine/RenderEngine.h>

class MyScene : public nero::Scene
{
    public:
        MyScene(nero::Scene::Context context):
            nero::Scene(context)
        {
            nero_log("Hello bodies");
        }

        void init()
        {
            nero_log("the init() method is called automatically after the constructor");

            //Create a mesh object and give it the name test "test" before to run this code
                auto object = m_ObjectManager.findObject("test");

                nero_log(_sn(object));

            // the little "_sn" is a toString method; the "s" is for String, the "n" is for Nero Object
        }
};

int main()
{
    nero_log("Nero Game Engine Hello World");

    nero::RenderEngine engine;
    engine.setScene<MyScene>("My Scene");
    engine.run();
}
 

4- No More DevScene

In some previous posts you may saw that a Scene could be created by inheriting from a nero::DevScene, this is no longer the case.
The DevEngine is only able to manage some nero::DevScene, so in principle you should only add DevScenes to it. In contrast the RenderEngine is only able to manage some nero::Scene. Switching between the DevScene engine and the RenderEngine, was requiring to manually change the inheratance of a Scene every time. I founded that combersome so, I made some changes.

Now only nero::Scenes are added to the DevEngine, and it is its responsibility to automatically generate a DevScene that will encapsulate the nero::Scene. With that, there is no change to made in a Scene when moving from the DevEngine to the RenderEngine and vis versa.

5- The  nero::GameEngine

You never heard about this Class. The reason is simply because it doesn't exist yet. The Nero project is based on three seperated Engines.
  • a Dev Engine, its role is to accelerate the development of a Game scene.
  • a Render Engine, its role is to facilitate Scene distribution, if you want a friend or a colleage to test a particular scene, put it in the RenderEngine and share it.
  • a Game Engine, its role is to hold a entire Game, a Game with multiple Scenes and  Menus. Its particularity is to have a Scene_Stack and a way to switch between Scenes and Menus easly.
A this stage of the project, the GameEngine is not a requirement, so I put it away for now.

That's all for this 101, the true tutorial will begin later on

40
SFML projects / Re: Nero Game Engine
« on: March 19, 2018, 02:05:46 pm »
Nero Game Engine Startup Kit

Hi every how are you doing !

The kit is now ready, you can download it with the link bellow. The kit works like a Codeblocks standalone installation. you can carry it in a USB key and launch it wherever you want. It uses a 32 bits MinGW compiler, so it should run on any Windows System.

Downlaod Nero Game Engine Kit

The Kit already contains two projects. One call "Test" that you can use as you want, and another call "Kero", I will talk about this one later.

The content of the Kit is as bellow

CodeBlocks/                  CodeBlocks and MinGW installation
Library/                  All the necessary headers, dlls and libs
Projects/                  All your projects should be created in this folder
Resource Pack/               A set of Textures and Fonts
Readme                     A readme file
Start                     Double click on this one to start CodeBlock;

There is nothing to configure, every new project has automatically access to the engine API

When you create a new project, there is only one thing to do. The Engine expect the "config/" and "Resource/" directories to be availabed. So don't forget to add them. You can simply copy the ones in the "Test" project in your New project directory.

41
SFML projects / Re: Nero Game Engine
« on: March 13, 2018, 02:20:33 pm »
Hi @Tank, thank for your reply.

I know the build and installation process maybe challenging, this is why I decided to add a scripting language at the final stage of the project. I didn't thought about a SDK, it's a great idea you have here. thank you !

By the end of the week, I'll provide a Kit fully Setup, the Kit will contains a CodeBlocks installation and a MinGW compiler fully configure.

42
SFML projects / Re: Nero Game Engine
« on: March 08, 2018, 08:43:16 am »
Build the Nero Hello World

Hi everyone, how are doing  ;D.

In this post I'm going to show how to build and run the Engine, The goal will be to make the following snippet of code work.

#include <NERO/engine/DevEngine.h>

int main()
{
    nero_log("Nero game engine Hello World");

    nero::DevEngine engine;
    engine.run();
}
 

This tutorial will focus on Windows, CodeBlocks and MinGW, if you are familiar with other tools, I'm sure you will find your way out too. Also I will asume that you know a bit of Cmake GUI

Step 1 : Download the Sources

All the sources are available on github

Boost 1.61.0 : https://github.com/boostorg/boost
Box2D 2.3.0 : https://github.com/erincatto/Box2D
SFGUI 0.3.1 : https://github.com/TankOs/SFGUI
SFML 2.4.0 : https://github.com/SFML/SFML
Nero 0.7.0 : https://github.com/sk-landry/Nero-Game-Engine

The Nero project use a specific version of the others libraries, you may try to use the latest version of the corresponding libraries, but for this tutorial I will stay with the specific versions in order to avoid any incompatibilities.

After downloading SFML, SFGUI, Boost and Box2D, you will have to checkout the sources in order to get the right version.

It's pretty easy. Here is a exemple with SFML

git clone https://github.com/SFML/SFML.git    // Download the SFML source code (latest version)
cd SFML                            // Move to the SFML source directory
git tag -l                            // Display all the available versions
git checkout tags/2.4.0                  // Switch the code to the version 2.4.0, the command is " git checkout tags/<tag_name> "

And there it is, you now have the SFML 2.4.0 version, you can do the same for Boost, Box2D, and SFGUI

Step 2 : Build the Sources

Build Boost

Let's begin by the easiest one, we are going to build only the system and the filesystem libs.

for that, move into the boost source directory and issue the following two commands one after another

./bootstrap.sh
./b2.exe --prefix=build --with-filesystem --with-system link=shared variant=debug,release threading=multi

The result of the build will be in the folder stage/lib

Build Box2D, SFML and SFGUI

Box2D, SFML and SFGUI can be build easly with Cmake GUI

SFGUI depends of SFML, if Cmake does not find SFML, you can define the Path option SFML_ROOT.

the sfml root directory should look like this
sfml_root_path/inlcude/SFML       //contains the sfml headers
sfml_root_path/lib                   //constains the sfml libs (.a files with MinGW)

Step 3 : Build Nero

After building Boost, Box2D, SFML and SFGUI you can now build the Nero project using Cmake GUI.

If Cmake does not find boost, you can define the Path option BOOST_ROOT

the boost root directory should look like this
boost_root_path/inlcude/boost       //contains the boost headers
boost_root_path/lib                 //constains the boost libs (.a files previously build)

If Cmake does not find SFML, you can Define the path option SFML_ROOT like for SFGUI

If Cmake does not find Box2D or SFGUI you will have to configure manually the following cmake options.

BOX2D_INCLUDE_DIR
BOX2D_LIBRARY_DEBUG                  
BOX2D_LIBRARY_RELEASE

SFGUI_INCLUDE_DIR
SFGUI_LIBRARY_DEBUG
SFGUI_LIBRARY_RELEASE

If you have built Box2D and SFGUI in Release and Debug mode, you can provide the two libs version, if not, providing either the Debug or Release libs will be enough.

Step 4 : Organise your Libs

When you build a library you can choose where the libs will be install. Libraries like Boost have default installation path, so cmake or any IDE or compiler can find them easily. Personnaly I use a custom folder call "Library" to store all my libs. It's easy to find them if I know they are all in one place. Choose the method that suits you the best.

In the next section I will assume that you have all the libs in a folder "Library" like this:

Library/include                               //contains all the libraries headers
Library/inlcude/SFML
Library/inlcude/Box2D
Library/inlcude/SFGUI
Library/inlcude/boost
Library/inlcude/json                            //   This one can be find in the Nero project source files, under the "extlibs" directory            
Library/inlcude/easyloggingpp                           // "extlibs" directory also

Library/lib                                             // contains all the libraries libs (.a files with MingW)
Library/bin                                              // conatains all the DLL files
Library/doc                                             // the libs doc

Step 5 : Link the lilbraries

Now that you have all the libs and DLL ready, you can create a new Project and make the following configurations.

On CodeBlocks, all of this is done in (Project --> Build Options)

activate the c++11 flag                  (Project --> Build Options --> Compiler Settings --> Compiler flags)
add the headers path "Libray/include"      (Project --> Build Options --> Search directories --> Compiler)
add the libs path "Library/lib"            (Project --> Build Options --> Search directories --> Linker)
add the dll path "Library/bin"            (Project --> Build Options --> Search directories --> Linker)

link all the libs                      (Project --> Build Options --> Linker settings --> Link libraries and/or --> Other linker options)

Step 6 : Mandatory directories

After linking the libs, there is one more thing to do, the Engine expect some directories and files to be available.

Resource/
Resource/Texture/
Resource/Font/
Resource/Font/Sansation.ttf         // This is one is important, the Engine use it for text rendering

config/
config/log_config               //Pretty important, but not necessary

You can download those directories here : https://github.com/sk-landry/resource-pack/blob/master/Directory.zip
Unzip the file and copy its content in your project directory

That's All

This post described all the steps you'll need to get start with the Engine. Build and Link libraries is one of the most difficult part when working on C++ programs. It may give you some headaches  ::)  :o :o. So try again and again if it does not work and feel free to ask any question in case of difficulties.

43
SFML projects / Re: Nero Game Engine
« on: February 12, 2018, 02:06:17 am »
Adding Cmake to the project

Cmake is now available in order to build the Library. I've successfully built the engine as Shared and Static lib on a 32 bits Windows using Mingw. I will test the build in other platforms later.

The cmakelists file I've built is pretty minimal, I will update it later, when i'll have a better understanding of Cmake.

For reminder the Nero Game Engine use the following libraries:
  • SFML 2.4
  • SFGUI 0.3.1
  • Box2D 2.3.0
  • Boost 1.61.0 (filesystem and system)

44
SFML projects / Re: Nero Game Engine
« on: February 04, 2018, 04:49:42 pm »
How is my game prototype doing !

I'm currently working on my game prototype, the objective is to simply test and improve the Engine. I'll be working on it all this month.

As for now I've implemented the following features.
  • Make the camera track my player
  • Move my player
  • Multi-Jump (double jump)
  • Dash
  • Moving platform
  • Go through Platforms when jumping from bottom
  • Make my player rotate to fit the ground slope, despite it is configured as Fixed_Rotation true
  • Remove objects at collision (It's like collecting coins or destroying enemies)

http://www.youtube.com/watch?v=FvEnGTooAag

The Nero Game Tools Library

The NGT (Nero Game Tools) Library is a sub-project of this current project.  It's goal is to provide a set of tools that will allow to prototype a game in hours, or build a first version of a game in only 2 or 3 days.

The first version of this library will be composed of the tools use in my game prototype. I plan to provide this library as a header-only library.

The library will be based on the concept of Action and ActionObject object. In the video above the code that make my player move is the same that make the platform move. I've just built a Move_Action that I can provide to any Object. Therefor the NGT library will be a collection on Action and ActionObject ready to use, you just configure them and set it to any object in the Scene.

The Second Release will come soon

After finishing with my game prototype, I will publish the first version of the  NGT  Library and make a tutorial on how to make a game from start to end with the Engine.

Only after that I will add Sound Object and Animation Object to the Engine.

45
SFML projects / Re: Nero Game Engine
« on: February 04, 2018, 03:58:27 pm »
Source code released

Hi! here, how are you doing ! ;D

The Engine source code has been uploaded on github, you can check the link bellow
Nero Game Engine Repository

From now on, I will update the repository after each progress in the engine development.

Need Help for the build process !

I will be working on the build process with Cmake in the following weeks, but I'm not an expert in Cmake, I may checkout the cmake files of projects like  SFML or SFGUI to find my way, but it'll take me months before to come up with a proper build process. So if anyone can help I'll be very thanksfull   ;D;

Resource Pack ! Thank Kenney !

I've searched for some free resources over the internet and finally found those beautiful textures made by Kenney Vleugels. The resources are free for both  personnal and commercial use. The work of this guy is just great !

I've gathered some of those resoures on a github repository call Resource Pack, check the link bellow
Nero Game Engine Resource Pack

The goal of the resource pack repository is to provide you all the resources you'll need to start with the Engine. Over the time there will be more resources like music, sound, particule and also more texture.

Pages: 1 2 [3] 4 5 6
anything