Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Game Engine

0.00/5 (No votes)
20 Nov 2009 1  
A game engine first prototype

Introduction

Engine is codenamed wg3dfx and works in an environment DirectX API, which means that it is adaptable to all versions of Windows (from version 2000 to Windows 7). Engine uses Truevision SDK 6.5, and to ensure the proper functioning of Truevision, you'll need to download the SDK 6.5 and MTV3D65.dll set as a reference. For audio support, wg3dfx used irrKlang and you will need to download and install the same. You can find more about it at woodgamesfx.

I call the code collection as game engine because it has almost all elements of game engine. You can use it as is or you can improve some parts of code.

Background

These are some screen shots:

Using the Code

The project is separated in three code sections: unit, scene and game engine section.

For example, this is the main game engine loop:

public void GameLoop()
{
    while (bLoop)
    {
        fTime = TV.AccurateTimeElapsed();

        if (SimuLatePhysics)
        {
            Fizika.PhysX.Simulate(TV.TimeElapsed() * 0.0025f);
        }
        if (Teren.Land == null)
        {
            Kamera2.Update(TV.TimeElapsed());
        }
        else
        {
            Kamera2.UpdateTerrainCamera(ref TV,  Teren.Land  );
        }
        GetMouseLandPosition = Teren.GetTerreinPosition(ref Scene, 
                               Kamera2.tmpMouseX1 ,Kamera2.tmpMouseY1 );
        UpdateScene();
        TV.Clear(false);
        Teren.DrawTerrain();
        if (SkyBoxs.Atmos != null)
        {
            SkyBoxs.DrawSkyBox();
        }
        Svijetlo.RenderLight();
        XActor.CrtajJedinice("Sve",ref Text2D,ref Globals );
        XModel.CrtajJedinice("Sve");
        Scene.FinalizeShadows();
        Partikali.DrawParticles("All");
        if (PodlogaTest != null)
        {
            PodlogaTest.DrawFlor();
        }

        if (Oblaci.Atmos != null )
        {
            Oblaci.DrawClouds();
        }

        if (Magla.Enabled)
        {
            Magla.DrawFog();
        }

        if (Voda != null)
        {
            Voda.DrawWatter();
        }       

        if (bDrawCoordinateSystem)
        {
            DrawCoordinateSystem();
        }
        VMannager.DrawVehicale();
        VMannager.CheckInputs(Kamera2._inputs, ref Fizika.PhysX);

        Dekoli.RemoveDecals(TV);
        Dekoli.DrawDecals();
        Scene.RenderAllMeshes(true);
        Scene.RenderAllActors(true);
        if (Kamera2.tmpMouseB1)
        {
            XActor.DeselectUnits();
        }

        if (Kamera2.tmpMouseB1)
        {
            Screen.Action_Begin2D();
            Screen.Draw_Box(XActor.Mouse1Coor.x,
            XActor.Mouse1Coor.y, XActor.Mouse2Coor.x,
            XActor.Mouse2Coor.y, Globals.RGBA(0, 1, 0, 1));

            Screen.Action_End2D();
        }
        XActor.UpdateActors(Kamera2.tmpMouseX1, Kamera2.tmpMouseY1, 
                            Kamera2.tmpMouseB1, Scene, Kamera2._inputs);
        TV.RenderToScreen();
        Application.DoEvents();
    }
}

In total, there are about 12,000 lines of code in all three sections.

Points of Interest

I will be publishing the first version of the open source engine very soon. Engine is in the development stage and some parts of code are not fully documented. I prohibit the use of parts of code, distributed library and executables for insulting the religious, racial, ethnic and gender level, causing damage to other parts of the code or using the files that come with WoodGamesFX. Software code and supporting files can be used for educational, commercial and noncommercial purposes as long as they meet the above-mentioned conditions. I will not be responsible for the use of code by the above conditions.

I hope that the information and content will benefit individuals or groups interested in creating computer games, simulations or other forms. We suggest you use this information for fun and learning.

History

I was developing this code for several months. If you have any questions about how to use the code, please send me an email at info@woodgamesfx.com.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here