week 5, Loading screen
|
As our game has grown larger and larger asset wise over the weeks I guess it’s not that surprising that there might be a great amount of data that needs to be loaded for the game to start. This could of course have been handled differently than we did but we chose to load every game texture as the game starts, in comparison to load everything as it is needed. This is also a viable way to do it as the game only has one level and is rather small. If the game would have had multiple levels I guess we should at least have loaded only the needed textures and sounds for the current level that was playing. Anyways, between the menu scene and the game scene we added our new loading scene. Before this we also added a texture cache class which would store all the needed textures for the game with a load- and a get texture function. The loading screen does the actual loading call for each texture to the cache class which may later be used in the game. It also loads in every sound needed through the sound manager which stores them for later use. Once the loading screen is displayed on the screen we wanted, as mentioned, something for the user to visually see assets being loaded and as for now this is represented by two growing bars in the middle of the screen. One for textures and one for sounds. To make these grow we added two integers to the loading scene which we added a value to in between each loaded item. This might most definitively be changed to a more fitting way to represent process and growth which are more relatable to the game. To make this feature work we used something called multi threading. (Be gentle with me from now on since my experience on this matter is below beginner level.) Anyhow, multi threading allowed us to do the loading process separately form the main process. Why? Because else we would have needed to call the draw function in between each loaded item as well as the integer additions. Now the main process only needed to keep track of those integers, scale the bars sprites accordingly and of course draw them to the window surface while the other thread loaded in the assets to its handlers.
|
