Jump to content


External Resource Manager And Loader

  • Please log in to reply
5 replies to this topic

#1 slayer_jojo


    GMC Member

  • New Member
  • 181 posts

Posted 16 July 2009 - 02:48 AM

Resource manager and loader
(Download link is at the bottom)

Advanced to expert users only.

See the second post where I give a bullet list of reasons why storing your resources externally is a VERY GOOD THING

This application manages external sprites, backgrounds and sounds. Here is the folder setup showing the folders and files you need to know:

You may be thinking "Wait a minute, how could I set options for external resources such as the bounding box, the origin, precise collision checking, and such?"

I have a system so you CAN. The settings are stored in the .ini files.

backgrounds.ini holds settings for your external backgrounds. sprites.ini holds settings for your sprites. sounds.ini holds settings for your sounds. More on this later.

The actual external resources can be put in the /backgrounds, /sprites or /sounds directory, depending on what type of resource is it. Sub-folders in these directories are also automatically imported so you can organize your resources as you would like.

Here is an example of how the sprites.ini file could look:



The section names should be the full name of the files you would like to configure. You may be able to guess what the above settings mean or you may not. Here is an outline of all the settings. Some are self-explanatory or are explained in the GM manual and aren't labeled.
Any resources that you do not define settings for will have default settings applied. Some settings do not do anything depending on if the file is a .png or not. png files will be loaded with their alpha values unless the alpha setting is set to 0
imgNumb = image number (eg if it is an animation strip)
transparent = whether transparency should be used in the case of a non-png file
xorig = x origin
origCenter = set this to 1 if you want the origin to simply be the center of the image (this is just convenient). Defaults to 0

//bounding box stuff
boundMode = precise|auto|full|manual  -  defaults to 'full'.  This is an option seen in the built in sprite editor
bound_left = defaults 0
bound_top = defaults 0
bound_right = defaults to right edge
bound_bottom = defaults to bottom edge

name = name of sprite as should be reference within the game.  Defaults to the name of the image without the extension
alpha = whether to use the alpha channel in the case of a png image.  Defaults to 1.

To reference a sprite in the game is simple:

//Example in the downloadable demo:
sprite_index = sprite.alphaDemonstation;

Just prefix the resource name with 'sprite.' or 'background.' This is actually nice as it is a form of "namespace". There is also a demonstration in the gmk file. See the testing room (bring it to the top and run the game to see it). Study the code in the objects put into that room.

Here are the available settings for external backgrounds
name = name of sprite as should be reference within the game.  Defaults to the name of the image without the extension
alpha = whether to use the alpha chanel in the case of a png image.  Defaults to 1

And here are the available settings for external sounds
kind = indicates the kind of sound (normal|background|3d|mmplayer)
preload = indicates whether the sound should immediately be stored in audio memory (0 or 1).
volume = (0 = low, 1 = high, default=1)
pan = (-1 = left, 0 = center, 1 = right)
tempo = the tempo of the music (if it is a midi file). 1 = normal tempo. Larger values = faster tempo, smaller = slower tempo. Must lie between 0.01 and 100.
name = name as it should be referenced within GM

There are two rooms in the demo. The first is the resource manager.

Resource Manager
Press Z to bring up a list of loaded sprites, X to bring up a list of loaded backgrounds, or C to bring up a list of loaded sounds. Click one to view it. It will then display the resource and demonstrate (some of) the configurations such as the bounding-box and origin in the case of a sprite. In the future it will display more settings and you will be able to modify the settings from the manager.

The second room in the .gmk is a demonstration of how you might use the resource loader in a game.

Using the Resource Loader
First, merge the .gmk with your game. Second, make sure to put the object controller in the room. It needs to be the first instance placed in the room (or at least before any instances that use external resources)/
To change the external resource loading screen, modify the scripts updateLoader() and initLoader() which are in the resourceLoader folder of the internal scripts

Download Program

Upcoming features:
* External tile layout editor
* Full external room editor (level creator)

Put it to good use. Suggestions? Ideas?

Edited by slayer_jojo, 25 July 2009 - 04:19 AM.

  • 0

#2 slayer_jojo


    GMC Member

  • New Member
  • 181 posts

Posted 18 July 2009 - 10:08 PM

let me outline why external resources is a VERY GOOD THING:

1. If you are using version control (especially if a whole team is using it), it makes a great complement for obvious reasons. Many people can work on the GM resources at the same time and submit changes at the same time.
2. Its great if you have multiple applications using a common set of resources. The resources stay perfectly synced. This is especially nice if you are making a level editor for a game, and doing so in a separate gm application file.
3. You can use your own custom loader.
4. You can more easily use your favorite resource editors (eg photoshop).
5. There resource pointers are stored in a respective object. For instance the sprite resource pointers are stored in the sprite object. This is a kind of name-space.
6. The default GM loader is faster when there are no internal images.
7. You can easily use .png images with alpha channels
8. The resources are more customizable through the ini files then they would be if stored internally

Edited by slayer_jojo, 22 July 2009 - 11:28 PM.

  • 0

#3 onpon4


    GMC Member

  • GMC Member
  • 1175 posts
  • Version:GM8

Posted 21 July 2009 - 01:10 PM

Take it as a compliment. On these forums, the worst stuff gets the most attention (albeit flaming), and awesome stuff gets the second-most. Anything in-between gets almost no attention at all.

So, you're in between, not awesome, but good. :P

Anyways, the main problem is you don't give much hint of how to use it. It utterly confuses me and it seems useless.

Edited by jaychant, 21 July 2009 - 01:15 PM.

  • 0

#4 slayer_jojo


    GMC Member

  • New Member
  • 181 posts

Posted 21 July 2009 - 08:55 PM

I suppose I did not give super precise instructions in some areas.. I'm about to release the next version which also supports backgrounds, and with it I'll write up more precise instructions for those who need it. Instead I had the demo (testing) room, which should show how to use it..

For large (and advanced) projects I very deeply believe an external resource system is needed.
  • 0

#5 slayer_jojo


    GMC Member

  • New Member
  • 181 posts

Posted 22 July 2009 - 11:31 PM

UPDATE July 22 2009
Here are the updates:
* Totally rewrote topic to give much much more precise details on how to use it. Please re-read it
* Backgrounds now supported
* Uses a dll for handling the ini files which is much faster
* Organized resources (eg scripts, objects, ini files)

UPDATE 2 (same day)
* Sounds now supported
* More options are displayed in the resource admin room

p.s. Please explicitly state any confusions you have

Edited by slayer_jojo, 23 July 2009 - 02:36 AM.

  • 0

#6 Reefpirate


    GMC Member

  • GMC Member
  • 335 posts

Posted 23 March 2012 - 05:20 AM

I guess it's kind of late... But I for one appreciate this idea!
  • 0
"All the meat, he thought, and all it wants.

'Wage,' she said, narrowing her eyes. 'He wants to see you with a hole in your face.'"


WIP: Chatsubo