GET STARTED

Welcome to this informative page, where you’ll be guided through the initial steps on the fascinating journey of crafting your very own game using GFX.

To be able to use the engine optimally, it is first necessary to download it. This is a straightforward process where you just need to select the latest release on Github. By taking this step, you not only secure access to the latest version of GFX, but also to numerous improvements, bug fixes and new features that are continuously provided by our dedicated development team.

You should also download the project template and add to Visual Studio.

Download the latest Version
Download Project Template

Create the Visual Studio project for the game

After successfully downloading the latest version of GFX and adding the project template to Visual Studio, we will create a new project using these files and add Genesis.dll as a reference. Ensure that the build is executed with the x64 settings.

CREATE YOUR FIRST GAME USING GFX

This code is designed to help you understand the workings of the game engine. The core concept is straightforward: there is a base class called “Game”, which organizes the project into various scenes.

A scene is essentially a class of its own. It contains different layers for game elements and can include multiple canvases for user interface components. As described earlier, the layers host game elements such as entities, sprites, or 3D models. These elements can be enhanced with scripts, known as “GameBehaviors”. The engine provides predefined behaviors, or you can create custom ones to suit your needs.

For more complex games, you can also inherit directly from the Scene class. This approach helps bring additional structure to your project, improving both organization and maintainability.

This version improves clarity and consistency, while emphasizing important terms with formatting for better readability.

Example Code

C#
using Genesis.Core.Behaviors.Physics3D;
using Genesis.Core.GameElements;
using Genesis.Graphics;
using Genesis.Graphics.Physics;
using Genesis.Graphics.Shaders.OpenGL;
using Genesis.Math;
using Genesis.Physics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GFXNetFrameworkTemplate
{
    public class MyGame : Genesis.Core.Game
    {
        /// An float value for the rotation
        private float m_elementRotation;

        public MyGame(IRenderDevice renderDevice, Viewport viewport, Window window) : base(renderDevice, viewport)
        {
            // Load the textures and set the target fps
            this.AssetManager.LoadTextures();
            this.TargetFPS = 200;

            // Create an sun and an physics handler for the scene
            var sun = new DirectionalLight("Sun", new Vec3(10.0f, 10f, 10.0f), 0.2f);
            var physicsHandler = new PhysicsHandler3D(0f, 0f, 0f);

            // Setup the Scene3D with an sun, layer, camera and physics handler
            var scene = new Scene3D("MyTestScene", sun);
            scene.AddLayer("BaseLayer");
            scene.Camera = new PerspectiveCamera(new Vec3(0.0f, 0.0f, -2.0f), new Vec3(1920, 1080), 0.1f, 100f);
            scene.Camera.Rotation = scene.Camera.Rotation.SetY(90.0f);
            scene.PhysicHandler = physicsHandler;

            // Create an 3D Element without animation. If you have an model with animation you need to use Model instead
            var element3D = new Element3D("sprte", "Resources/Models/Guitar/Guitar.fbx", new Vec3(0, 0f, 0f), new Vec3(0, 0, 0), new Vec3(1f, 1f, 1f));

            // Create an collider behavior and setup the physics for it
            var collider = element3D.AddBehavior<BoxCollider>(new BoxCollider(physicsHandler));
            collider.CreateCollider();

            //// You can transform the collide with this functions. It will also transform the Element3D
            collider.Rotate(45, 0, 0);
            collider.Translate(0, 0, 0);

            // Lets assign an more fancy shader to the Element
            element3D.Shader = new SpecularShader();
            scene.AddGameElement("BaseLayer", element3D);

            // Add the Scene to the game and load it.
            this.AddScene(scene);
            this.LoadScene("MyTestScene");

            // Setup an debug drawer for physics debuging
            this.OnInit += (g, r) =>
            {
                physicsHandler.PhysicsWorld.DebugDrawer = new BulletDebugRenderer(renderDevice);
            };

            // Render the physics
            this.OnRenderEnd += (g, r) =>
            {
                physicsHandler.PhysicsWorld.DebugDrawWorld();
            };

            // Update the game
            this.OnUpdate += (g, r) =>
            {
                // update the rotation
                m_elementRotation += 0.01f;
                m_elementRotation %= 360.0f;

                // Rotate the collider. The Element will follow the collider!
                collider.Rotate(new Vec3(m_elementRotation, 0, 0));
            };
        }
    }
}

GET THE EXAMPLE PROJECT

To deepen your understanding, you can download a sample project directly from our GitHub page. This example project serves as a practical demonstration, offering hands-on experience with the concepts discussed. By examining the code, structure, and functionality of the sample project, you can gain a clearer and more tangible understanding of how the game engine works.

Get the example project