Game Resources

This how to article shows you how to load and manage a resource.

Pascal
Resource management in Pascal can be done very easily by editing the file GameResources.pas. To load the resources, you will need to place your resource files to the appropriate location. All images should be placed in the images folder in the Resources folder. All sound files should be placed in the sounds folder in the Resources folder. All fonts should be placed in the fonts folder in the Resources folder. All map files should be placed in the maps folder in the Resources folder.

After you have placed a resource file, you will need to call:
 * NewFont from LoadFonts to load a font.
 * NewImage from LoadImages to load an image.
 * NewTransparentColourImage from LoadImages to load an image with transparent key colour.
 * NewSound from LoadSounds to load a sound effect.
 * NewMusic from LoadMusics to load a music.
 * NewMap from LoadMaps to load a map.

For example, this will load a music file called showcase.mp3 and name it Showcase.

A loaded resource can be loaded from game very easily. You will need to call LoadResources routine at the start of your game to initialise the resources. To obtain a resource, you will need to call the following.


 * GameFont to obtain a font.
 * GameImage to obtain a bitmap.
 * GameSound to obtain a sound effect.
 * GameMusic to obtain a music.
 * GameMap to obtain a map.

For example, this will obtain a music data and play it. You will need to specify the name of the resource to obtain a data.

This should make the resource management very simple.