How to make a loading screen?
I'm making an RPG game and the map is 10000 pixels by 10000 pixels(One of the maps I should say) and on my computer it takes about 1-3 seconds to load, but on my girlfriends laptop it takes about 6-8 seconds and I was just wondering if it was able to make a loading screen. So that you didn't just have to look at black, I did think of other ways of doing it, like only loading 640, 480 pixels around you as you walk but I just thought that it would be nice to learn something new today if it's not to much trouble for you to explain how I would go about doing that.
Threads. Main thread displays loading animation. Second thread loads image. When second thread finishes, it signals main thread and loading screen completes.
It can be done even without I suppose, although depending on the loading method. You may split loading work to multiple smaller ones and update the animation in between them.
However, majority of simple applications just show a loading image for that purpose. This way you just first load & display small image and then load the heavy stuff.
Could any of you give me some example code, or point me to a web site that teaches me what I need to know. It would be much appreciated
With Allegro 5.0:
1// mark as volatile so that the compiler knows it may unexpectedly change
done_loading = false;
me, void *
data; // aren't using this. this is the NULL parameter from below
my_bitmap = al_load_bitmap("foo.bmp");
10 // load other bitmaps
done_loading = true;
14 // when running an attached thread, the following is the return value to
15 // al_join_thread(), which we are not using here.
19// starts the loading thread
22// this code will execute while the above function is running
26 // show loading page, etc
Normally you'd need to convert the bitmap to video after that while loop is over because the loader thread will create it as memory. However, in your case, the video card is not going to support a video bitmap of that size, so it doesn't matter. (But if you are loading smaller bitmaps, you'd need to convert them to video.)
Threading can get complex because you normally don't want two threads reading and writing the same data at the same time. However in this case, since one thread is writing a boolean that the other thread only reads, it will be safe. For more complex interaction, you need to use mutexes and condition variables.
Anyway, all that said, the real solution is not to use a bitmap that large...
Thread #609387. Printed from Allegro.cc
Agreed there, I think you should look into using tile maps, in stead of using such a huge background image.