Loading screens.

Started by Borislav, September 15, 2018, 12:05:45

Previous topic - Next topic

Borislav

Is it possible to create a real loading screen in BlitzMax?
Is there a specific module I could download for that?

fielder

Loading screen is probably just a PNG placed on the center of screen.
if you have to load a huge amount of data from harddrive... just refresh the view... and add some animation during this file-reading.

Borislav

Quote from: fielder on September 15, 2018, 13:53:59
Loading screen is probably just a PNG placed on the center of screen.
if you have to load a huge amount of data from harddrive... just refresh the view... and add some animation during this file-reading.
But doesn't the loading screen determine when the data is loaded and when it isn't?

Derron

output <> input

loading screen = "output"
loading files = "input"

-> Loading screen just shows what currently is loaded.

After each "LoadImage()":
- increase "files loaded" (you also need a "files to load" total count if you want a "x percent loaded" display)
- do a "DrawMyLoadingScreen(); Flip 0" and in this "DrawMyLoadingScreen()" you do a Cls + Draw some text + loadingbar which takes "files loaded" into consideration


bye
Ron



Yellownakji

#4
I manage my projects with "loops".    I have 'app_loop' which is a string that stores the current loop i want to render.  Loops are function that call certain crap in a certain order, inside the main loop.

So for example, if i'm in the options menu, my app_loop would be set to "m_options"...

-------------

In my main process loop, i do this:


'Drawtext("no loop, retard",3,3) 'if no loop is found, you'll just have a black screen with this mocking you.

if app_loop = "m_options" 'options menu
'loop shit here
end if

if app_loop = "m_main" 'main menu
'loop shit here
end if



-------------

Once you manage your loops, it's easy to make a loader.    Just create a variable called "load_loop:string" and create a loop called loader.

When you want to load, just set app_loop to loader.   You can load specific things by checking load_loop.

-------------

You can check if an instance exists in memory with "if [variable]"....  so if you want to check if a player graphics exists,  you can do:


if app_loop = "loader"

if load_loop = "load_player

if gfx_player:timage
'the shit exists, so you can skip it
else
gfx_player = loadanimimage(blah blah blah)
end if

'here you can add a loading complete check;  you can make a variable that goes up each time something loads or is skipped; when it hits the target value, loading is done.
'when loading is done, you can create a check and then set your app_loop to equal load_loop.
'always define your load_loop before you set app_loop to loader.

end if

end if


A rough explanation of my loader.  You can go far more advanced and you should probably add a delay so you don't strain the CPU if you need to load a million things at once.

---------------

OH, and if you want to have a loading graphics or some kind of icon,  every time you check and load for something,  pause the loader.   when the loading code is finished, you can draw those goodies after in the frame.  then when the loop repeats itself for the next frame you can have something like loader_paused = false. 

Yellownakji


Henri

Hi,

there is a sample in Blitzmax 'Samples / Threads' folder called background_loading.bmx . This demonstrates how you can use threads to load your assets and has a 'screen' that you can update accordingly.

-Henri
- Got 01100011 problems, but the bit ain't 00000001