Samael88
Evil always finds a way
- Reaction score
- 181
Hi everyone.
It sure was a long time since I posted here, but I have run into another problem when developing my game
I think that I get the basic builds of a program and such, but I can't figure out a good way to load my images
Or more precicely, when to load them.
My build so far is I got a game loop like this:
1. My first choise is to declare them as globals, and then load them in the loop. at the 1. and clean them at the end.
2. My second choise is load them whenever I enter a loop, and thus have a secondary bool to check if the loop has ran once, and another to check if it should cleanup. The variables are also declared as globals for this to work.
3. A third alternative would be to load them in the respective function like this:
I can't really figure out which one to use, and perhaps there is a better alternative that I have not thought of yet. Help, anyone?
It sure was a long time since I posted here, but I have run into another problem when developing my game
I think that I get the basic builds of a program and such, but I can't figure out a good way to load my images
Or more precicely, when to load them.
My build so far is I got a game loop like this:
Code:
while [quit == false] //main loop
{
//1.
while[mainmenu == true] //main
{
//2.
//handle main menu functions here..
mainmenufunc();
}
}
1. My first choise is to declare them as globals, and then load them in the loop. at the 1. and clean them at the end.
2. My second choise is load them whenever I enter a loop, and thus have a secondary bool to check if the loop has ran once, and another to check if it should cleanup. The variables are also declared as globals for this to work.
3. A third alternative would be to load them in the respective function like this:
Code:
mainmenufunc()
{
static bool ran_once = false;
static bool exit = false;
if (ran_once == false)
{
ran_once == true;
//declare images and load them.
}
//do main menu stuff
if (exit == true)
{
//cleanup the images
}
}
I can't really figure out which one to use, and perhaps there is a better alternative that I have not thought of yet. Help, anyone?