Well, earlier today I realized my mario-clone was taking a while to load mainly due to the audio files and partly due to the many sprites being loaded. It wasn't a real problem, but it seemed rather unproffesional to have the computer pause for a while without any feedback for the user to confirm that anything was happening. Initially I used System.Console.WriteLine("Loading Something...") for the various resources that I had. This works fine for debugging, but whenever I tried to organize a loading bar that the user could see on a devoted portion of my game I experienced some trouble. First off, I'm using game states to determine whether I'm loading, at the menu, or playing the game, these aren't a problem. Secondly I'm using a rather mediocre way of deciding how many resources have been loaded, I'm simply increasing an integer value below the code that loads my resource. It's simple but it works for my purposes. This integer value directly affects the width of my loading bar tick's (looks like a '|' ) destination rectangle, this stretches my image to achieve the desired look of the bar filling up.
All of this works except that the loading bar doesn't show the intermediate positions, rather it is either completely empty or completly full. This is due to all my loading code being in its own method, and whenever I do spriteBatch.Draw() the various textures that make up the bar aren't shown until the spriteBatch.End() at the end of my method, which is too late because by then all the resources have been loaded, so the bar is completely full. I think I remember reading (possibly in Shawn Hargreaves notes on SpriteBatches) about a setting which displays textures immediatly after each spriteBatch.Draw(), however if I'm just exhibiting some wishful thinking, then how might I show the textures individually in a fast way. Currently I've been experimenting with a spriteBatch.Begin - Draw - End for each time the bar has increased in size but this has proved to only yeild errors.
Much thanks to anyone who could help me solve this conundrum!
On a somewhat related note, does anyone know how to get the percentage of a number I know, this seems quite easy but for some reason everytime I try to assign an integer or double to a value that should return something other than zero, all I get IS zero. For example:
int inPercentage = (15 / 30) * 100;
From what I've learnt in math this should result in inPercentage having a value of 50, or 50% but from my experience it's always resulted in 0. When I do the same thing with a double I get the same result. I feel as though this is due to some extremely small thing that I'm completely overlooking, so hopefully someone on this forum will notice that small mistake and correct it . Thankyou for any help on the matter.