GTCS Game Engine:
Tutorial 0: Setting Up the Environment

Tutorial 0 --> Tutorial 1
Main tutorial guide page


Introduction

The GTCS Game Engine consists of numerous files in a very specific file hierarchy. The details of how the files work is beyond the scope of these tutorials. In this tutorial, you will learn how to setup an IDE for programming and understand the file structure for the engine and your game.

Source code for tutorials can be downloaded from here.

Development EnvironmentEntry Point


Development Environment

To develop your game, you will want to use an integrated development environment (IDE) and a runtime web browser that is capable of hosting the running game engine. We have found that the most convenient combination is the NetBeans IDE with the Google Chrome web browser. The products are free, work across a number of OS platforms and integrate well for web development. Here is a rundown of this combination of tools...

Once you have all of these tools installed, you can use NetBeans IDE to write your game. When you select to run your game from NetBeans, Google Chrome will launch showing you the results. The IDE will show any errors that it comes across during operation.


Entry Point

To run your game, you will need an HTML shell running on a web server. This file must reference all of the files that make up the engine and the fies that are specific to your game. By convention, this file is named index.html and is stored at the same level as the assets folder and src folder of the engine.

The format of your HTML file can be broken down into three sections...

onload

The entry point for your code will be an object you design that is a subclass of the engine's "Scene" object. You will first allocate a new instance of your class and send it into the game engine as shown in the following code snippet.

<body onload="
	var mainGame = new MyGameScene();
	gEngine.Core.initializeEngineCore('GLCanvas', mainGame);
">
Code snippet 0-1: onload

Note: The portions in bold are the sections that are specific to your game implementation.

JavaScript Includes

This code can be dropped into your HTML file as-is for all cases. The last line is an exception. This is where your custom code needs to be added. If you have multiple files, you need an include for each file. Again, the order is important so be sure you know what order things are being referenced.

<!-- the following says there are javascript source code contained in 
         the external source files
    -->
    <!-- external library -->
    <script type="text/javascript" src="src/lib/gl-matrix.js"></script>
     
    <!-- Engine code -->
        <!-- Core of Engine --> 
            <script type="text/javascript" src="src/Engine/Core/Engine_Core.js"></script>
            <script type="text/javascript" src="src/Engine/Core/Engine_VertexBuffer.js"></script>
            <script type="text/javascript" src="src/Engine/Core/Engine_GameLoop.js"></script>
            <script type="text/javascript" src="src/Engine/Core/Engine_Input.js"></script>
            <script type="text/javascript" src="src/Engine/Core/Engine_Physics.js"></script>
            <script type="text/javascript" src="src/Engine/Core/Engine_Particle.js"></script>
            <script type="text/javascript" src="src/Engine/Core/Engine_LayerManager.js"></script>
            <!-- Resource support -->
                <script type="text/javascript" src="src/Engine/Core/Resources/Engine_ResourceMap.js"></script>
                <script type="text/javascript" src="src/Engine/Core/Resources/Engine_TextFileLoader.js"></script>
                <script type="text/javascript" src="src/Engine/Core/Resources/Engine_DefaultResources.js"></script>
                <script type="text/javascript" src="src/Engine/Core/Resources/Engine_AudioClips.js"></script>
                <script type="text/javascript" src="src/Engine/Core/Resources/Engine_Textures.js"></script>
                <script type="text/javascript" src="src/Engine/Core/Resources/Engine_Fonts.js"></script>
        <script type="text/javascript" src="src/Engine/Scene.js"></script>
        <script type="text/javascript" src="src/Engine/Material.js"></script>
        <!--Lights -->
            <script type="text/javascript" src="src/Engine/Lights/Light.js"></script>
            <script type="text/javascript" src="src/Engine/Lights/LightSet.js"></script>
        <!-- Utilities -->
            <script type="text/javascript" src="src/Engine/Utils/Transform.js"></script>
            <script type="text/javascript" src="src/Engine/Utils/BoundingBox.js"></script>
            <script type="text/javascript" src="src/Engine/Utils/Interpolate.js"></script>
            <script type="text/javascript" src="src/Engine/Utils/InterpolateVec2.js"></script>
            <script type="text/javascript" src="src/Engine/Utils/ShakePosition.js"></script>
            <script type="text/javascript" src="src/Engine/Utils/CollisionInfo.js"></script>
        <!-- Renderables -->
            <script type="text/javascript" src="src/Engine/Renderables/Renderable.js"></script>
            <script type="text/javascript" src="src/Engine/Renderables/TextureRenderable.js"></script>
            <script type="text/javascript" src="src/Engine/Renderables/TextureRenderable_PixelCollision.js"></script>
            <script type="text/javascript" src="src/Engine/Renderables/SpriteRenderable.js"></script>
            <script type="text/javascript" src="src/Engine/Renderables/SpriteRenderable_PixelCollision.js"></script>
            <script type="text/javascript" src="src/Engine/Renderables/SpriteAnimateRenderable.js"></script>
            <script type="text/javascript" src="src/Engine/Renderables/FontRenderable.js"></script>
            <script type="text/javascript" src="src/Engine/Renderables/LineRenderable.js"></script>
            <script type="text/javascript" src="src/Engine/Renderables/LightRenderable.js"></script>
            <script type="text/javascript" src="src/Engine/Renderables/IllumRenderable.js"></script>
            <script type="text/javascript" src="src/Engine/Renderables/ParticleRenderable.js"></script>
        <!-- Shadows -->
            <script type="text/javascript" src="src/Engine/Shadows/ShadowCaster.js"></script>
            <script type="text/javascript" src="src/Engine/Shadows/ShadowReceiver.js"></script>
            <script type="text/javascript" src="src/Engine/Shadows/ShadowReceiver_Stencil.js"></script>
        <!-- GameObject -->
            <script type="text/javascript" src="src/Engine/GameObjects/GameObject.js"></script>
            <script type="text/javascript" src="src/Engine/GameObjects/GameObject_PixelCollision.js"></script>
            <script type="text/javascript" src="src/Engine/GameObjects/GameObjectSet.js"></script>
            <script type="text/javascript" src="src/Engine/GameObjects/TiledGameObject.js"></script>
            <script type="text/javascript" src="src/Engine/GameObjects/ParallaxGameObject.js"></script>
        <!-- Particles -->
            <script type="text/javascript" src="src/Engine/Particles/Particle.js"></script>
            <script type="text/javascript" src="src/Engine/Particles/ParticleGameObject.js"></script>
            <script type="text/javascript" src="src/Engine/Particles/ParticleGameObjectSet.js"></script>
            <script type="text/javascript" src="src/Engine/Particles/ParticleEmitter.js"></script>
        <!-- Physics -->
            <script type="text/javascript" src="src/Engine/Physics/RigidShape.js"></script>
            <script type="text/javascript" src="src/Engine/Physics/RigidShape_Collision.js"></script>
            <script type="text/javascript" src="src/Engine/Physics/RigidShape_Behavior.js"></script>
            <script type="text/javascript" src="src/Engine/Physics/RigidCircle.js"></script>
            <script type="text/javascript" src="src/Engine/Physics/RigidCircle_Collision.js"></script>
            <script type="text/javascript" src="src/Engine/Physics/RigidRectangle.js"></script>
            <script type="text/javascript" src="src/Engine/Physics/RigidRectangle_Collision.js"></script>
        <!-- Shaders -->
            <script type="text/javascript" src="src/Engine/Shaders/SimpleShader.js"></script>
            <script type="text/javascript" src="src/Engine/Shaders/TextureShader.js"></script>
            <script type="text/javascript" src="src/Engine/Shaders/SpriteShader.js"></script>
            <script type="text/javascript" src="src/Engine/Shaders/LineShader.js"></script>
            <script type="text/javascript" src="src/Engine/Shaders/LightShader.js"></script>
            <script type="text/javascript" src="src/Engine/Shaders/ShaderLightAtIndex.js"></script>
            <script type="text/javascript" src="src/Engine/Shaders/IllumShader.js"></script>
            <script type="text/javascript" src="src/Engine/Shaders/ShaderMaterial.js"></script>
            <script type="text/javascript" src="src/Engine/Shaders/ShadowCasterShader.js"></script>
        <!-- Camera -->
            <script type="text/javascript" src="src/Engine/Cameras/Camera.js"></script>
            <script type="text/javascript" src="src/Engine/Cameras/Camera_Manipulation.js"></script>
            <script type="text/javascript" src="src/Engine/Cameras/Camera_Input.js"></script>
            <script type="text/javascript" src="src/Engine/Cameras/Camera_Xform.js"></script>
            <script type="text/javascript" src="src/Engine/Cameras/CameraState.js"></script>
            <script type="text/javascript" src="src/Engine/Cameras/CameraShake.js"></script>
            
   
    <!-- Client game code -->
        <script type="text/javascript" src="src/MyGame/MyGameScene.js"></script>
Code snippet 0-2: Include Files

Canvas item

The canvas is where the rendering of your game will occur. You need to define the pixel width and height. The engine will look for the DOM object called "GLCanvas" and handle the rest.

<canvas id="GLCanvas" width="500" height="400">
        <!-- this message will show only if WebGL failed to load-->
        Your browser does not support the HTML5 canvas.
</canvas>
Code snippet 0-3: Canvas

Conclusion

Now that we have setup our files and created our web page, we can go on to implementing code for the game. In tutorial 1, we will look at the components that make up our scene and draw a simple object to our canvas.


Tutorial 0 --> Tutorial 1

2/11/2016 - David Watson