Project Information

  • Language: C++
  • Graphics API: DirectX 11
  • Creation: Y3 S2
  • Source URL: GitHub Page

Roche Engine

Created as part of my Group Game Development module in semester 2 of my third year. The Roche Engine is a 2D and 3D game engine which was created using DirectX 11. The engine was created with the intention of being used in the creation of a 2D game, which was also created by my group. The engine was created using the entity-component system and abstraction to allow for the simple creation of new entities, sprites and tiles within the scene. The engine also includes a UI editor which allows for the creation of UI elements within the scene, a tile map editor which allows for the creation of tile maps and a projectile editor which allows for the creation of projectiles which can be fired from the entities. The sound engine was created using XAudio2 and can be used to play sounds within the scene, or attach them to entities so that they play when certain actions are performed by the entity, such as colliding with other entities.



What Did I Learn?

During the creation of the Roche Engine, I learned a lot about the creation of game engines and the different features which can be implemented within them. I also learned a lot about the applications of the entity-component system and how it can be used to attach store singular system functionality in components which can then be bound to an entity based on the type of entity that is created. This system was repurposed for use in the UI editor, to allow for developers to create widgets with varying functionality based on the type of widget that was created. Namely, the creation of buttons which can be used to perform actions when clicked, and the creation of text boxes which can be used to display text within the scene.

The main skill that I developed while working on the Roche engine was ImGui docking. I learned how to use ImGui docking to create a custom viewport which could be used to display the scene and the different editors which were created for the engine. I also learned how to use ImGui docking to create a custom docking system which allowed for the docking of windows within the viewport, and inside each other with options for resizing to suit the needs of the developers.

// Get the maximum size of the window
ImVec2 vRegionMax = ImGui::GetWindowContentRegionMax();
ImVec2 vImageMax = ImVec2(
    vRegionMax.x + ImGui::GetWindowPos().x,
    vRegionMax.y + ImGui::GetWindowPos().y );

// Get the ratio of the image to the window
ImVec2 vRatio =
{
    m_gfx->GetWidth() / ImGui::GetWindowSize().x,
    m_gfx->GetHeight() / ImGui::GetWindowSize().y
};

// Check if the image is fit to width or height
bool bIsFitToWidth = vRatio.x < vRatio.y ? true : false;
ImVec2 ivMax =
{
    bIsFitToWidth ? m_gfx->GetWidth() / vRatio.y : vRegionMax.x,
    bIsFitToWidth ? vRegionMax.y : m_gfx->GetHeight() / vRatio.x
};

// Get the position of the image
ImVec2 pos = ImGui::GetCursorScreenPos();
Vector2f half = { ( ivMax.x - vRegionMax.x ) / 2, ( ivMax.y - vRegionMax.y ) / 2 };
ImVec2 vHalfPos = { pos.x - half.x, pos.y - half.y };

// Get the maximum position of the image
ImVec2 ivMaxPos =
{
    ivMax.x + ImGui::GetWindowPos().x - half.x,
    ivMax.y + ImGui::GetWindowPos().y - half.y
};

// Draw the image
ImGui::GetWindowDrawList()->AddImage(
    (void*)m_gfx->GetRenderTargetPP()->GetShaderResourceView(),
    vHalfPos, ivMaxPos );
Rendering the main scene window into an ImGui window is handled separately and is demonstrated in the above code snippet, but the general process for achieving this is to render the scene to a texture using the RTT method, and then to add that texture to the ImGui draw list. The process for achieving this such that the scene window would always constrain to a 16:9 aspect is as follows.

  1. Get the maximum size of the window

  2. Get the ratio of the image to the window.

  3. Check if the image is fit to width or height.

  4. Get the position of the image.

  5. Get the maximum position of the image.

  6. Draw the image.

Future Additions

Having worked on Roche engine, I have a much better understanding of the creation of game engines and the different features which can be implemented within them. I would like to continue working on the Roche engine in the future, and to add more features to it. I would like to add a particle system to the engine, which would allow for the creation of particle effects which could simply be achieved by repurposing the projectile system. I would also like to add a networking system to the engine, which would allow for the creation of multiplayer games in the engine.

I would also like to continue working with the other members of Nine Byte Warriors to create more games using the Roche engine, or use it to develop a game as part of a game jam.


Feel free to drop a comment below.