1
Graphics / ImageManager
« on: June 26, 2011, 03:50:44 pm »
Hi, I am creating class that has image manager from sfmlwiki to load images and vector< vector ... <sf::Image*> ..> to keep images and animations in 1 global class for quickier access (Image manager keeps Images by string "path" and these vectores keeps Images by index and loades them from ImageManager to prevent loading the same image)
something like this:
class SuperImageManager {
/*5d vector*/ character[sex][body part][direction][animation][frame]
/*2d vector*/ texture[number]
/*3d vector*/texture_animated[animation][frame] //all sf::Image *
...
ImageManager im;
};
class Character{
int direction;
int state; // walking/running/standing...
int action // fighting/jumping...
sf::Image *..*animation;
}
Character ch();
ch.animation = SuperImageManager.character[0] // eg 0 = male 1 = female...
and then:
App.draw(ch->animation[body_part][direction][state][action][int some_anim_func_Update()]);
...
The point is:
a) isnt this totally stupid?
b) if I reserve place for vectores in SuperImageConstructor() by this:
for ( int i = 0; i < SOMEINT; i++ )
{
this->(*..*character).push_back ( vector< <vector... <sf::Image*> >..>);
for ( int j = 0; j < OTHERINT; j++ )
{
this->(*..*character)[j].push_back ( vector< <vector... <sf::Image*> >..>);
for (int k = 0; k < ANOTHERINT; k++)
{
.
.
.
}
}
}
or vector.reserve
And I dont load every image on program start up (eg only character animations. Terraint textures, trees etc on map loading) does the vector need to realloc space when I have every sf::Image pointer reserved (I know how many pictures will I load) and I do character[j][k]..[z].LoadFromFile/ImageManager() )
Also who understand what I am trying to say with my crappy english is awesome
something like this:
class SuperImageManager {
/*5d vector*/ character[sex][body part][direction][animation][frame]
/*2d vector*/ texture[number]
/*3d vector*/texture_animated[animation][frame] //all sf::Image *
...
ImageManager im;
};
class Character{
int direction;
int state; // walking/running/standing...
int action // fighting/jumping...
sf::Image *..*animation;
}
Character ch();
ch.animation = SuperImageManager.character[0] // eg 0 = male 1 = female...
and then:
App.draw(ch->animation[body_part][direction][state][action][int some_anim_func_Update()]);
...
The point is:
a) isnt this totally stupid?
b) if I reserve place for vectores in SuperImageConstructor() by this:
for ( int i = 0; i < SOMEINT; i++ )
{
this->(*..*character).push_back ( vector< <vector... <sf::Image*> >..>);
for ( int j = 0; j < OTHERINT; j++ )
{
this->(*..*character)[j].push_back ( vector< <vector... <sf::Image*> >..>);
for (int k = 0; k < ANOTHERINT; k++)
{
.
.
.
}
}
}
or vector.reserve
And I dont load every image on program start up (eg only character animations. Terraint textures, trees etc on map loading) does the vector need to realloc space when I have every sf::Image pointer reserved (I know how many pictures will I load) and I do character[j][k]..[z].LoadFromFile/ImageManager() )
Also who understand what I am trying to say with my crappy english is awesome