Windows External VS. Internal Files

Jaqueta

Member
Well, I have a lot of questions that are related to this: External Vs Internal Files (Sprites, to be more Specific)

Ok, on my game, the player can choose between different Texture Quality options, I did that, by creating multiple sprites with different sizes, for instance:
upload_2016-7-29_13-39-28.png
I have a player character 64x64, and I have duplicates by the size of 48x, 32x and 16x.

Code:
tex_list[tex_count]=argument0
tex_count++
return asset_get_index(argument0+ts_posfix+string(global.ts_tex_qual))
On the start of the game, I store the sprite ID on a global variable,

Code:
//Delete the unused sprites from the game to free up memory
for (j=0; j<4; j+=1)
{
    if not j=global.ts_tex_qual
    {
        for (i=0; i<tex_count; i+=1)
        {
            sprite_delete(asset_get_index(tex_list[i]+ts_posfix+string(j)))
        };
    }
};
And then, I use the sprite_delete function for the other 3 sprites that won't be used in the game.

Now that you know what is going on, the questions:
1 - Would be better for me, to put the Sprites as external files, and instead of deleting the existent ones that are included in the game, just load the one necessary?
2 - How does that affects performance? Does external files use more Texture Swaps/Batch Breaking?
3 - The External Files are included in a single bundle file, I'm correct or wrong? And, it's possible for the players to open and modify these files, so they can create mods and stuff if they want? (Honestly, that would be a plus)
4 - If not ^, is it possible for me to implement some sort of "mod_override" folder? (If you don't know what this is, Payday 2 have a really nice override system.)
5 - Using musics as external files is better too?

Thank you for reading my post and annoying questions. ;D
 
N

Noele

Guest
Texture pages are created at compile time so deleting images from them afterwards will not reduce their size.
Creating sprites dynamically at run-time (loading them externally) creates a texture page for each sprite, which increases the texture page swaps required when each is used, which can cause a performance hit.
The file bundle is generally in a read-only location on most platforms. All saving is performed to the designated safe save area for that platform and this would be the location you could place your Mods Folder.
Streamed music is loaded externally as and when required on most platforms anyway so this isn't generally an issue.

It really depends upon the target platform as to the approach - memory and performance play a big part.
 

Jaqueta

Member
Thanks for the answers.
When I talked about mod the file bundle, I meant, externally, unpack the file, edit the resources and pack it again.

One last question, is a good idea to create an Audio Group for each music and then load the group only when I need to use it and after using unload it?

Thanks again. ;D
 
N

Noele

Guest
External files are exported at run-time and honestly, you should not encourage your users to modify anything in the file bundle. If you want them to alter files externally (to create Mods) do so in the designated safe save area for that target platform. Most (modern) OS won't allow general user access to the file bundle anyway, which is usually what you want.

Studio games will look in the designated save area first for a file and then in the file bundle if it fails yo locate it. The file bundle has the defaults, the save area can have the Mods. That's basically how it works but look up File System Limitations in the manual for details.

As for audio groups I seldom find the need to use them, at least not for HTML5 games.
 

Jaqueta

Member
Well, as the subject suggests, I'm exporting for Windows (YYC).
Anyway, thanks again for your answers.
 

YanBG

Member
Noele is right and you'd better keep the sprites in the resource tree but i don't think having 3 resolution versions for all character sprites is a good idea, because it would probably take too much time to produce. How do you create them?

I'm making a game for Windows(hopefully released on Steam) and it goes with an installer. I wanted the instalation folder to look tidy, so this is how it went:

  • the game is called Bogarash(the exe)
  • all sprites from the resource tree are bundled in Data(i'm not sure if the scripts/objects are there too)
  • the Audio Groups bundle dialogues which i don't want to be accessible(it's useful in the coding as well, if you want to stop all sounds of particular Group)
In the 4 folders are all my included files
  • half are text and ini(contain enemy and item stats, for easier balancing)
  • Sounds has all the music which is streamed and if the tracks were in the resource tree, i couldn't create new folder for them and they will flood the root directory(they are about 40)
  • Textures folder has a few big menu backgrounds, for which i can afford separate texture pages.
I'm quite happy with this structure because it supports modding(to an extent). You can edit or replace(the png and ogg) any of the included files in the game directory as long as their names match.

 

Jaqueta

Member
The sprites, I create them in the highest resolution, and then resize (10 seconds per sprite basically), even the lowest resolution, which is Pixel Art is pretty fast to do because most of them are 16x16. And the performance benefit for those who doesn't have a good machine, is great.

2. About the songs and how they populate the directory, I'll consider it, but I don't think that it's a big deal because 95% of the people won't even open the Game Folder when playing xD

3. I did the same with my some of my backgrounds too :p

Thanks for helping me!
 
Top