Loading Included Files without freezing?

W

Wonamik

Guest
Hi,

When I am loading files from Included Files the whole game freeze untill its loaded. Is it possible to allow some objects to not freeze? Basically so I can have a load screen animation.

Best Regards Wonamik
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
If you are a loading a large number of files then this is not possible unless you decide to load them in "batches". For example, say you have ten files to load, then what you'd do is load the first two and update the loading screen, then call the next two and update, etc... until all are loaded.
 
E

elementbound

Guest
@KingdomOfGamez I like your idea, although I'd suggest a modified version:
Code:
if(model1 == undefined) {
    model1 = d3d_model_load(model1, "model1.d3d");
    image_index = 1;
    exit;
}

if(model2 == undefined) {
    model2 = d3d_model_load(model2, "model2.d3d");
    image_index = 2;
    exit;
}

// ...
( You may have to initialize your variabled to undefined in the Create event, not sure about that )

What I did for a game I'm working on is to create an object with a list. This list contains type-data pairs, where data can be multiple items if needed. Imagine something like:
Code:
resources = ds_list_create();
ds_list_add(resources,
    "mesh", "player.bob", // "mesh", filename
    "texture", "player-tex", "player.png", // "texture", name, file - textures are accessed by name
    "mesh", "skybox.bob",
    "texture", "bg1/sky", "bg1/tex/sky.png");

res_at = 0;
In each step, the loader grabs all the data needed for the next resource ( while incrementing res_at ) and loads a single resource.

This way I can easily calculate progress ( (res_at+1) / ds_list_size(resources) ), and I can use that to draw whatever kind of progress bar I wish. Even though the way I calculate progress is not necessarily accurate, it is still a good indicator.

In the actual game, this system is a bit more sophisticated tho - I create similar lists as "resource packs" and queue them into the loader's list with ds_list_add(batchloader.resources, "reslist", global.rqBg2);. The (batch)loader remembers these lists by index, and if I happen to add the list a second time, the loader will just skip it.
 
W

Wonamik

Guest
Also what do you guys think is the absolute maximum loading time a game should be allowed to have before its too much?
 
E

elementbound

Guest
Depends on the game, but I would not like to spend more than two minutes at a loading screen. Even if it's an interesting one :p
 
I

icuurd12b42

Guest
Also what do you guys think is the absolute maximum loading time a game should be allowed to have before its too much?
It depends. there better be a fantastic game on the other side of the loading if it's more than 20 seconds.

What sort of files are you loading and what file io functions are you using
 
W

Wonamik

Guest
It depends. there better be a fantastic game on the other side of the loading if it's more than 20 seconds.

What sort of files are you loading and what file io functions are you using
The thing that takes sooo long to load is the JSON files done in Spine. most are fine, but I have some BIG bosses with lots of attacks and many moving things and yeah they take looong. Also I havent even started with the sound yet does those files take long to load?
 
I

icuurd12b42

Guest
The thing that takes sooo long to load is the JSON files done in Spine. most are fine, but I have some BIG bosses with lots of attacks and many moving things and yeah they take looong. Also I havent even started with the sound yet does those files take long to load?
Hmm, so you are loading the spine file manually?

this is the proper way to load json text file
Code:
///map_from_json_file(filename)
var ret = undefined;
if(file_exists(argument0))
{
    //create a buffer from file, it's a fast read
    var buf = buffer_load(argument0);
    //read the string from the buffer, returns the entire content
    var s = buffer_read(buf,buffer_string);
    //decode to map
    ret = json_decode(s);
    /free buffer
    buffer_delete(buf);
}
//return map or undefined on fail
return ret;
 
Top