Functionality of loading screen

Hello!
I’m really interested in understanding of how can I optimize a game with a loading screen in BGE. I searched a lot about this theme and for most part I found that loading screen is a just an screen with animation while BGE loads a game itself. But, as we know, the first starting of a game could be laggy (https://blenderartists.org/forum/showthread.php?418599-Game-slow-at-startup).

So, I want to know, making a loading screen is just an animation screen (with loading bar) or I can somehow to manipulate through python what bge should load first (and fix that with a showing ready percent of loading bar) and etc.? I’m also asking this, because I want to know, is it real to eliminate that laggy first loading or I should put up with this?

Thanks.

A loading screen is just a static image. The BGE loads single threaded. That means there will be no updates on the shown image (no animations, no changing text, no progress bar).

You can use LibLoad to asynchronously merge scenes into an existing scene. While doing so, the BGE still runs your game. This means you can animate whatever is present in your scene already.

Most of the lag you see when first starting a Blender game is the game engine converting everything from blender objects to blender game objects. It has to do a lot of work to get your assets ready for play.

Separating your assets out in to different scenes or blends can reduce this lag, as it only loads a little at a time. Also you can use libload to load only the assets you need, again, this saves time.

But it’s difficult to make a dynamic loading screen for this first stage as most of the work goes on behind the scenes in the very bowels of the BGE.

Loading screens are something people always want. In my most recent project I have this:

(First 10 seconds).

First thing to realise is that this is extremely hard to do, and you have to plan your game structure realising that you will need a loading screen.

The major issue with making a loading screen is separating out all of the parts of your game. By default, blender loads everything in your blend into ram as soon as you switch to the scene. If you want a meaningful load screen, you need to separate it out so it can be done incrementally, over several frames.

In the above project, I separate it out into a whole heap of different parts, things like:

  • Load in each ship
  • Load in a whole bunch of lights
  • Cache the sound effects in RAM
  • Load some dynamic textures (such as the ship and level preview images) from disc
  • Load the level

As well as a few other things. Essentially, this is done by, on the first frame, compiling a list of every function that needs to be run before the game ‘starts.’ Then I run them, one at a time, until their are none left. Then I start the game.

My advice is to research and experiment with the three dynamic loading options in BGE:

  • LibLoad
  • AUD
  • bge.texture.ImageFFMPEG

Libload is the most useful, merging two scenes so that you can have one that starts off empty, and you gradually populate it. AUD does all the sound handling, allowing you to avoid lag when you first hear a sound, and ImageFFMPEG is useful for when textures need to change. All of those three things take time to run, and if run over multiple frames, make for a useful load screen.

To my knowledge, very very few BGE users ever make load screens. The extra complexity is seldom worth it. If your load time is under two seconds, don’t bother.

I forgot about using aud to cache the sounds. Thanks for reminding me.
Recently I had a game where there was a small lag the first time you do any action, I couldn’t think what it could be. But I suspect that it was the sound effect being loaded fof the first time. I’ll have to rewrite my audio manager…

Here is an loading screen that i have build, it simply load in blends into a main blend.

Thanks, guys! It’s a very interesting and useful information. I’ll try to use LibLoad. I’m appreciate for other your advices.