Load Game Resources

In this tutorial, you will learn how to load some game resources

Resource Type & Resource Folder

When you go to your project folder under the Engine SDK Projects Folder, you will find a folder named resource. This folder contains all the resource needed by your game with one exception which we will talk about later.

Inside the resource folder you have one folder for each type of resource the engine is able to handle.

  • Font
  • Texture
  • Animation
  • Sound
  • Music
  • Shader
  • Script

How to load resources ?

Load resources is pretty easy, you just have to copy the resources in the right folder and the Engine will load them automatically when it starts up. If you put a resource in the bad folder nothing will happen, the Engine will ignore that resource.

Resource Configuration

The Engine uses a configuration file to filter resources and to allow you to change some parameters used when loading resources.

{
   "animation": {
      "extension": [
         "png",
         "jpg",
         "bmp",
         "dds",
         "tga",
         "psd"
      ],
      "folder": "resource/animation"
   },
   "font": {
      "default": "Sansation",
      "extension": [
         "ttf",
         "otf"
      ],
      "folder": "resource/font"
   },
   "music": {
      "extension": [
         "wav",
         "ogg",
         "flac"
      ],
      "folder": "resource/music"
   },
   "script": {
      "extension": [
         "lua"
      ],
      "folder": "resource/script"
   },
   "shader": {
      "descriptor": "resource/shader/shader.json",
      "extension": [
         "vert",
         "frag"
      ],
      "folder": "resource/shader"
   },
   "sound": {
      "extension": [
         "wav",
         "ogg",
         "flac"
      ],
      "folder": "resource/sound"
   },
   "texture": {
      "extension": [
         "png",
         "jpg",
         "bmp",
         "dds",
         "tga",
         "psd"
      ],
      "folder": "resource/texture",
      "separator": "-"
   }
}

Mandatory Resource - The Default Font

The Engine needs one mandatory resource which is the Default Font. You can choose any font to be the default font, but you have to have one. If you want to select a certain font has to default one, simply copy that font in the font folder (resource/font), then go to the configuration file and set the name of that font without the extension. If font is named my_font.ttf you simply need to set “default” : “my_font”.

{
   "font": {
      "default": "my_font",
      "extension": [
         "ttf",
         "otf"
      ],
      "folder": "resource/font"
   },
}

Startup Resources

As said above, all resources needed by your game are in the Resource folder with one exception. The Startup folder contains the resources used during your game startup or if you prefer, during your game loading screen. These resources are not loaded automatically.