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.
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#
usingGenesis.Core.Behaviors.Physics3D;usingGenesis.Core.GameElements;usingGenesis.Graphics;usingGenesis.Graphics.Physics;usingGenesis.Graphics.Shaders.OpenGL;usingGenesis.Math;usingGenesis.Physics;usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceGFXNetFrameworkTemplate{publicclassMyGame : Genesis.Core.Game { /// An float value for the rotationprivatefloatm_elementRotation;publicMyGame(IRenderDevicerenderDevice, Viewportviewport, Windowwindow) : base(renderDevice, viewport) { // Load the textures and set the target fpsthis.AssetManager.LoadTextures();this.TargetFPS =200; // Create an sun and an physics handler for the scenevarsun=newDirectionalLight("Sun", newVec3(10.0f, 10f, 10.0f), 0.2f);varphysicsHandler=newPhysicsHandler3D(0f, 0f, 0f); // Setup the Scene3D with an sun, layer, camera and physics handlervarscene=newScene3D("MyTestScene", sun); scene.AddLayer("BaseLayer"); scene.Camera =newPerspectiveCamera(newVec3(0.0f, 0.0f, -2.0f), newVec3(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 insteadvarelement3D=newElement3D("sprte", "Resources/Models/Guitar/Guitar.fbx", newVec3(0, 0f, 0f), newVec3(0, 0, 0), newVec3(1f, 1f, 1f)); // Create an collider behavior and setup the physics for itvarcollider= element3D.AddBehavior<BoxCollider>(newBoxCollider(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 =newSpecularShader(); 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 debugingthis.OnInit += (g, r) => { physicsHandler.PhysicsWorld.DebugDrawer =newBulletDebugRenderer(renderDevice); }; // Render the physicsthis.OnRenderEnd += (g, r) => { physicsHandler.PhysicsWorld.DebugDrawWorld(); }; // Update the gamethis.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(newVec3(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.