Resource loader, any suggestions?

Started by
4 comments, last by funvill 18 years, 4 months ago
Hello I was thinking about making a resource loader for 2d game engine, I have an idea of how I think it should work, Any suggestions, comments or links to articles or tutorials would help greatly. I was thinking of creating a XML file with a list of resources, Fonts Sound Textures Each item will have a unique ID and a path. For example



<node>
    <media>
        <!-- Black Arial font 12 pt -->
        <fontXX id="1" size="12">
            <file>Arial.TTF</file>
            <color red="255" blue="255" green="255" />
        </fontXX>
        <!-- Red Courier font 24 pt -->
        <fontXX id="2" size="12">
            <file>Cour.TTF</file>
            <color red="255" blue="0" green="0" />
        </fontXX>
        <texture id="3" width="32" height="32">
            <file>Bug.tga</file>
        </texture>
        <texture id="4" width="32" height="32">
            <file>ghost.tga</file>
        </texture>
        <texture id="5" width="32" height="32">
            <file>fruit.tga</file>
        </texture>
        <texture id="6" width="32" height="32">
            <file>wall.tga</file>
        </texture>
        <soundFX id="7">
            <file>waka.wav</file>
        </soundFX>
        <soundFX id="8">
            <file>BMG.mp3</file>
        </soundFX>
    </media>
</node>


I would create a tool that would generate this XML file and compress all the media in to one big file. Then I would create a small library that would load the XML file and decompress the media to memory and load the media in to my 2D Engine Any suggestions?
====Funvill[Home|Tiny xml|Boost|Wiki|STL]====================
Advertisement
Sounds good. Is there anything in particular you'd like more info on?
:stylin: "Make games, not war.""...if you're doing this to learn then just study a modern C++ compiler's implementation." -snk_kid
Nope, I just wanted to make sure that my theroy was sound, and i'm not reinventing the wheel

====Funvill[Home|Tiny xml|Boost|Wiki|STL]====================
Hey funvil,

I have an idea for ya, first, your id's. What if you wanted to add a texture, you'd have to add it to the end of your list, so it just seems to me, it looks like a flat file, rather than a heirarchy with that id hard coded. So, I would suggest, why even have it.


XML is a heiarchy so you can have more like this:

<node>    <media>        <font>            <file>Arial.TTF</file>            <color>                <red>255</red>                <blue>255</blue>                <green>255</green>            </color>            <size>12</size>        </font>        <font>            <file>Cour.TTF</file>            <color>                <red>255</red>                <blue>0</blue>                <green>0</green>            </color>           <size>12</size>        </font>    </media></node>


I like the values more, cause color now can have RGB components, or RGBA components and it doesnt need to have properties all over the place, just an idea.

Also,
For file loading, I like doing it filesystem based, everything in the data folder it loads and stores, you can supply properties to objects in xml, but you might as well load whats in the directory so its easy to add a resource or delete it.

Just some things to think about, I by no means know what the best solution is.

Jeff.
Any reason you prefer tag data over properties? I've been prefering properties but maybe it's not a good idea?
Quote:Original post by SnadderLars
Any reason you prefer tag data over properties? I've been prefering properties but maybe it's not a good idea?


I always just perfered tag data over proerties because it found it easier to read, the proerties would problaby be better since the file size would be smaller
====Funvill[Home|Tiny xml|Boost|Wiki|STL]====================

This topic is closed to new replies.

Advertisement