• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Toshi Brown

Loading Screen Functionality (States)

5 posts in this topic

Hey guys,


Im currently programming a game using Allegro 5 (written in C++) and im looking for functionality regarding Loading Screens.


I suspect it will be a state in between my "TITLE SCREEN" state and my "PLAYING" state.


Can anyone tell me if it is possible to include a Loading screen bitmap with a "progress bar"?


If so, could you also guide me to a resource or point me in the direction to find out more?






Share this post

Link to post
Share on other sites

this can be accomplished several ways.


if you simply want a load screen, with no feedback, then using a state for loading is fully reasonable, however if you want a progress bar, things get a bit interesting.


either you:

1. use multi-threading/async loading, in which case, you need some method to post a percentage complete(for example, at specific point's in the load, pass an value to some variable that say's "i'm 10% done, 20%, etc.), or if loading multiple resources, and you only want to pass back what the file is your currently loading, then before opening a file, simply pass the filename string to some varaible to be rendered over your loading screen.


2. if single-threaded, post redraws at those percentage points, simply clear the screen, draw w/e your loading screen is, and flip the screen(disabling v-sync would be important here)


any decent content manager should incorporate such functionality for anything it's capable of loading, however if your loading the files directly yourself, it might by a bit tricker to incorporate such functionality.

Edited by slicer4ever

Share this post

Link to post
Share on other sites

I see, thanks slicer, thats very helpful!


At the moment I am creating art for the various screens, and I can now confidently build the loading screen.


Share this post

Link to post
Share on other sites

I had some thoughts about loading screens too.

In general, putting up a simple bitmap before starting loading is simple enough. And as slicer said, there's a couple of ways to do a loading bar. 


Since I do my own loading, I have the following idea:

I assume that only 1 and only 1 loading screen will be shown at a time. This meant that I can stick it as a globally accessible property in my singleton interface class. So, to access the loading screen, I would do Interface::I().GetLoadingScreen(); - which would return me the main loading screen. From there, I can then proceed to set its properties like background image, percent loaded etc.


The good thing about this is that since I have my interface drawing setup, i don't have the worry about drawing the screen at all - it's automatically done by the interface. I just have to call a Show/Hide loading screen function to make it show / hide. 

Having a loading screen like that also allows me to write code in the Interface to automatically disable all input whenever the loading screen is shown - so that's another thing I don't have to worry about when loading stuff, since it will be done when I tell the UI to show the loading screen.


The requirement for this, however, is that I must put all my loading into separate threads. The basic flow in my main thread (that handles drawing / updating / input) is like this:

1. User triggers loading

2. I start a new thread to do my loading, so I don't block the main thread.


And in the loading thread:

1. Set UI to show loading screen

2. Set the background graphic / initial percent loaded (usually 0%)

3. Do my loading here, while periodically updating the percent loaded based on what I'm loading

4. Set UI to hide the loading screen.


The UI will automatically handle displaying the loading screen, blocking all user input and updating the loading bar on the screen.

Normally with multi-threading you'd need to have a mutex on the values you're changing, but in this case, I think I can get away without any, since there's nothing critical there, and the UI will only read the values, while the loading thread will only write them.


Share this post

Link to post
Share on other sites

Hey Toshi....I'm also using Allegro 5 for my current project.    I ended up creating a LoadScreen class which is capable of presenting a screen of messages to let the user know the status of the load.   Like Milcho I disable input while this screen is up.   Now I don't have a progress bar, but it wouldn't be too hard to add based on the way I've put this together.    The key would be knowing ahead of time how many things you are going to load, which in my current setup I don't know.
To give you an idea...
Loadscreen class is really simple...

class LoadScreen
    void Destroy();
    void AddMessage(std::string);
    void Display(float);
    void ClearMessages();

    std::string messageQueue[5];


Then as I'm looping through loading all my graphics, entities, etc.   I call this inside the loops...





LoadingScreen is just an instance of LoadScreen.

Message is a std::string of whatever I want to update the user about

The float that gets passed into Display() is a "pause time" the artificially slows down the display so you can read the messages.


(and yes I know this isn't the best code in the world....this is an area of my product thats on the eventual refactor list...but it works for now)


Share this post

Link to post
Share on other sites

My loading screen is a static class with a static function, because I won't need to display more than one screen at a time. So, similar to Milcho's setup. It also stores a list of the resources to load in a queue, to send to special content loader made for this type.


Here is some of my code in the loading screen. I've generalized the loader class to be any type of file you may want. I'm not familiar with Allegro or what ALLEGRO_BITMAP supports, but the trick is to go through each item frame by frame.


BitmapLoader Bitmaps;


void LoadState::update()

	if (!Bitmaps.queueEmpty()) {

		if (!Bitmaps.fileLoaded())

if (!Bitmaps.doneProcessing()) {

// Add to the data buffer



else {

/// Add the bitmap to the scene and then clear buffer
// Move on




Granted, I only needed to do this with 3D meshes, as it sometimes took more than a few seconds to load files in one go. For more complex assets such as meshes, I broke it down into smaller discrete parts of data, process a certain number of those at a time and treating that as one complete "item". One pass of processing is done per frame. Textures didn't need a lot of attention yet, but I didn't use too many of them so they were loaded in just one frame.


If individual files don't take too long, you can perhaps make your object loader more generic to read everything from map files to sounds or bitmaps. Then choose a certain number of files to load each frame, take that number and divide by the total of files on your list to determine the loading progress.

Edited by CC Ricers

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0