GML Load times: What are they, and when/why are they needed?

Dr_Nomz

Member
Just curious because I never seem to run into load times during gameplay when testing the game I'm developing (aside from initial start up) so can someone explain to me what they're used for in Game Maker?
 

Lukan

Gay Wizard Freak
They aren't a feature, as you seem to imply they are.
Larger games or games that have large amounts of data need to make sure that data is loaded before it's used or presented to the player.
Load times are the time where this data is loaded/sorted into memory for accessing later.
They aren't a controllable thing per se. You can optimise your games and dress up your load screens to make them seem less like waiting, but it's just a necessity of how computers work.
 

Mert

Member
Computer programs use CPU/GPU/Disk Space/RAM all combined. Naturally, they must balance the work in order to work properly. For example, once you finish playing the Level 1, you can now remove the level 1's data from the RAM and load level 2's data. Doing all the task during gameplay would not look good because this is an expensive task for the computer. So you put a small loading screen to make it look smooth.

However, some modern games actually ditched the loading screens and managed to do this on runtime, smoothly.
 

Dr_Nomz

Member
So wait, if I just have a bunch of rooms that the player can go to, are they only loaded once the player is actually in that room, or do I have to do something specific to make sure that room isn't loaded in?

Also can someone give me an example of how load screens are worked in? I'm just curious how that works.
 

NightFrost

Member
You don't really see loading times / screens on GMS games as they're normally singular packets that have been loaded into memory. For example graphically heavy 3D games have so much textures that there's no way it all could fit into memory at once. Instead they manage memory resident stuff by discarding needless textures and loading relevant ones. And that's just graphics, same would go for audio assets and I'm pretty sure they load and unload pieces of code as well when necessary. GMS doesn't do any of this by itself so you'd have to write your own handlers, except for code which I assume is impossible to load runtime.
 
Another reason for load times can be procedurally generating content. Dwarf Fortress is a perfect example for this, because the load times are going to directly correspond to how much "world" you want to generate. If you try doing a lot of proc gen with GMS, depending on what type of generation you are doing, you'll occasionally encounter "patches" of generation that causes the game to freeze up. This proc gen that causes sluggish behaviour is what you then move into the loading screen, so you can get those areas that are causing freezing up in a controlled environment that the player recognises as acceptable.
 

Dr_Nomz

Member
Okay but let's say I run a script that freezes the game for a second, and I use it at the start of each room any time the player enters a new area, how would I work a load screen into that situation?

Only asking here because I can't find a youtube tutorial on load screens. :/
 

Xer0botXer0

Senpai
I've actually done this before lol,

don't remember how I did it but this is how I might:

Code:
if display_Loading_Screen == true
{
       instance_create(x,y,obj_Loading_Screen);
       var seconds = room_speed * 5;

       for (i = 0; i < seconds; i ++)

       if i >= seconds
       {
              if instance_exists(obj_Loading_Screen)
              {
                     with(obj_Loading_Screen)
                     {
                            instance_destroy();
                     }
              }
       }
}

display_Loading_Screen = false;
}
Then you just give obj_Loading_Screen an animated sprite.
 

TsukaYuriko

Q&A Spawn Camper
Forum Staff
Moderator
Just curious because I never seem to run into load times during gameplay when testing the game I'm developing (aside from initial start up) so can someone explain to me what they're used for in Game Maker?
Loading time isn't exactly "used for" anything. If you have load times, or the freezes associated with not having a loading screen mask them, it's a sign that you're trying to do more than your target device can do within one frame. It's based on the exact same principle as lag, except that freezes are an even higher escalation of the causes of lag (doing more than the device can handle) over extended periods of time.

It's like telling an employee that they have to do 1000% of their usual workload today in the middle of their daily routine, and that they have to take care of the additional work immediately. In a world where a "day" doesn't end after a defined amount of time, they will eventually complete their job that day, but it'll take them longer than usual and they will have to drop their routine while they're working on the extra workload.

So wait, if I just have a bunch of rooms that the player can go to, are they only loaded once the player is actually in that room, or do I have to do something specific to make sure that room isn't loaded in?
They are loaded when you enter and unloaded when you leave them.

Okay but let's say I run a script that freezes the game for a second, and I use it at the start of each room any time the player enters a new area, how would I work a load screen into that situation?

Only asking here because I can't find a youtube tutorial on load screens. :/
I guess that leads us to the "real" topic title: "How to display a loading screen rather than freezing?"

To put it simply: Probably not at all.

Normally, you'd implement this by offloading whatever loading tasks you have to a separate thread, then displaying some sort of animation as the loading screen the player sees. This main thread would wait for the loading thread to complete before the game continues.

The problem with that is that there are no threads in GML aside from the main one. You can't spawn new threads, at least not by default. There were some extensions for old and not so old versions to add this functionality in a limited manner, but whether they work for the current version and how long they will continue to do so is a separate question.

Lacking threads, the only thing you can do is to manually interrupt and then resume your loading code the next step.
For example, imagine you're loading a map with a size of 100x100 tiles, and every second, for the sake of simplicity, you can load exactly 100 tiles. This would mean that every 100 tiles, you'd have to stop loading and resume next step.
Ideally, you won't do this after a specified amount of loading has taken place, but after a certain amount of time has elapsed since the beginning of the frame. This amount of time should be less than the duration of one frame at your target frame rate, taking into consideration that drawing the loading screen will also take time - let's say if one frame takes 16ms, cutting it off at 10ms should be a safe bet unless drawing your loading screen takes 6ms, at which point you'd have a bigger problem to take care of.

Failing even that, your fallback would be to set an alarm to 1, draw a (static) loading screen during the first frame (and only during the first frame), and one step later execute your loading code. This will draw a "loading screen" while the loading takes place, although the game will be unresponsive and frozen during this time.
 
There's a couple of things about loading screens that can be a bit counterintuitive with GMS. Firstly, if you want an animation to "run" while the game is loading instead of just a static screen, you'll have to cut your loading code up into chunks and run each chunk consecutively on each Step, otherwise you'll have a single long held frame while everything actually loads and then your animation will run after that rather than during. This can be done multiple ways, but the easiest one for me has been to simply set up an alarm and a load_counter variable. The alarm holds a switch statement using the load_counter variable which runs a particular piece of loading code based on the which number the load_counter is. You then simply increment load_counter each time the alarm fire and set the alarm to 1 after each code chunk (remember to NOT set the alarm on the final load chunk).

When you go to the new room that you need to load for (or when you want to load something, this doesn't have to be room based). You'll set a show_load (or whatever) variable to true. Then you set your load alarm (what I described in the previous paragraph) to 1. This gives the game enough time to render the first frame before the loading begins. In your draw gui event (or draw event depending on how you have things setup), you then have an if (show_load) statement that encompasses what you want displayed when the game is loading. If you have an animated sprite being shown, each animation frame will fire once per alarm trigger and depending on how much loading you are doing in each chunk, this can give a jerky appearance to the animation, but without GMS being multi-threaded this is the best you'll get out of the box and besides, players are accustomed to load screen animation not playing 100% smoothly all the time. Once you have finished loading what you need (perhaps in the last switch case of load_counter), you'll set show_load to false.

This is probably the easiest and quickest way to set up a relatively good loading system that I've come up with.
 

dannyjenn

Member
Somebody on here (I forget who) uses loading screens for ads. (I think the actual loading happens very quickly, but he keeps the "loading screen" on there for another 15 or 30 seconds, in order to display the ads.)

I suppose with certain kinds of games, you could also use these sorts of loading screens to break up the gameplay at convenient times, such as to give the player a short pause between levels.

But generally, loading screens are for loading. If your game isn't loading a huge amount of data (from external files and whatnot), you probably don't even need any loading screens. (Same for "saving screens".)
 
Somebody on here (I forget who) uses loading screens for ads. (I think the actual loading happens very quickly, but he keeps the "loading screen" on there for another 15 or 30 seconds, in order to display the ads.)
I do this, I keep the loading screen up for 10 seconds and show an ad; that way the ad is not intrusive in the game play.
 

Joh

Member
I do this, I keep the loading screen up for 10 seconds and show an ad; that way the ad is not intrusive in the game play.
Getting sidetracked a bit, but what do you think of "break time" or cooldown. (inspired by cytus, but I'm sure others do it too)
Since I don't like ads and fear my users might not like them either, I'm trying an hybrid where sometimes there is a delay (15 sec OR ad).
This way ads (and "load" times) show up every now and then rather than being a constant. (+eventual paid version with none of that)

Just not sure my "generosity" is worth it, though I would feel dishonest masking it as a 10sec+ load time, when my game doesn't even need loadings.
 
Personally, from a users stand point I think it's a terrible idea and I hate it. But, from a deverloper's standpoint that needs to make money and survive it doesn't sound like such a bad idea :) I think if you wanted to do this the critical thing would be finding a good middle ground. It will also depend on the overall value of your game. If your game is just mediocre, then having 10 second ad delays might be more than someone is willing to give you. If the game is fun and enticing then you could probably get away with 30 second delays. It really just depends.
 
  • Like
Reactions: Joh
As a player I would never notice if a load screen is needed or not; so as a developer I made the choice that this is where I put my ads. I HATE games (and this is getting even more common) that have 3-4 ads on the playing screen, while you are playing - and then more ads on transition screens. There are some games that are unplayable because of ads.

Just not sure my "generosity" is worth it, though I would feel dishonest masking it as a 10sec+ load time, when my game doesn't even need loadings.
That is a call you have to make, ads are a current method of getting paid and therefor a necessary evil.
 
  • Like
Reactions: Joh

TsukaYuriko

Q&A Spawn Camper
Forum Staff
Moderator
If the game's process doesn't report any activity or increase in regards to CPU, RAM or disk usage, the player can be pretty certain the loading screen is fake. Your ordinary player won't check this while playing the game, of course...
 

Joh

Member
Personally, from a users stand point I think it's a terrible idea and I hate it. But, from a developer's standpoint that needs to make money and survive it doesn't sound like such a bad idea :) I think if you wanted to do this the critical thing would be finding a good middle ground. It will also depend on the overall value of your game. If your game is just mediocre, then having 10 second ad delays might be more than someone is willing to give you. If the game is fun and enticing then you could probably get away with 30 second delays. It really just depends.
Pretty much how I feel too... except 30 sec would be pushing it! But I guess it varies by people. Noticing I might be an outlier in terms of tolerance is what made me think: maybe I shouldn't try to be "considerate".
As a player I would never notice if a load screen is needed or not; so as a developer I made the choice that this is where I put my ads. I HATE games (and this is getting even more common) that have 3-4 ads on the playing screen, while you are playing - and then more ads on transition screens. There are some games that are unplayable because of ads.


That is a call you have to make, ads are a current method of getting paid and therefor a necessary evil.
Haven't really faced overkill ads but for me it would have to be a choice, banners all the time or transition ads, but not both. But maybe I'm again being naive.

As for the necessary evil, I agree and that's why I asked. In a way: loading ad feels like a good use of loading time, while sporadic ads feel like a sporadic waste of time. but every time with no loading is the "feel" of a no ads experience. I was more curious on as user feelings.

common sense would expect Less ads = better; but I also feel consistent load ads has its own charm.
 
Top