1
General / Re: vector with multiple classes | Drawing order
« on: November 28, 2014, 09:25:54 pm »
I've now got std::map to work as a reference holder, by looking at the use of map in the sfml book code
resourceholder, with I allready use in my menu and map classes.
And I've placed the instantiation of Animclass map & Drawable vector
in the scene change loop so they destroy by them self.
As has be suggested.
The structure now look like this.
resourceholder, with I allready use in my menu and map classes.
And I've placed the instantiation of Animclass map & Drawable vector
in the scene change loop so they destroy by them self.
As has be suggested.
The structure now look like this.
file:Define_Intro.cpp
// - layer 0
{ AnimCLASS tmp("Background", 0, true, true, 1,0, "textures/Art01", 0,0, 1,1);
AnimMap.insert(std::make_pair(id, tmp));
auto found = AnimMap.find(id);
DrawVec.push_back(&found->second); id++}
void SceneCLASS::SetUp(AudioCLASS &audio, MouseCLASS &mouse, int SN
, std::vector<DrawableCLASS*> &DrawVec, std::map<int,AnimCLASS> &AnimMap )
{
int id = 0;
if (SN==Intro){ #include "Define_Intro.cpp" }
//
//
for (auto& item : DrawVec) {
item->Init();
if(item->GetClickPoint().Enable) {
// push Dynamic clickpoints
CPSceneVec.push_back(item->GetClickPoint() );
}
}
};
void GameCLASS::Start()
{ bool exit_loop = false; int SceneNumber = 0;
do{
if( SCENE.NextScene == SceneNumber)
{
std::map<int,AnimCLASS> AnimMap;
std::vector <DrawableCLASS*> DrawableVec;
SCENE.SetUp(Audio,Mouse,SceneNumber,DrawableVec, AnimMap);
Run(DrawableVec, SceneNumber);
}
SceneNumber++;
if(SceneNumber>=NumberofScenes) SceneNumber=0;
if(SCENE.NextScene == 99) exit_loop=true;
}while(!exit_loop);
};
int main()
{
GameCLASS GAME;
GAME.SetUp();
GAME.Start();
return 0;
}
// - layer 0
{ AnimCLASS tmp("Background", 0, true, true, 1,0, "textures/Art01", 0,0, 1,1);
AnimMap.insert(std::make_pair(id, tmp));
auto found = AnimMap.find(id);
DrawVec.push_back(&found->second); id++}
void SceneCLASS::SetUp(AudioCLASS &audio, MouseCLASS &mouse, int SN
, std::vector<DrawableCLASS*> &DrawVec, std::map<int,AnimCLASS> &AnimMap )
{
int id = 0;
if (SN==Intro){ #include "Define_Intro.cpp" }
//
//
for (auto& item : DrawVec) {
item->Init();
if(item->GetClickPoint().Enable) {
// push Dynamic clickpoints
CPSceneVec.push_back(item->GetClickPoint() );
}
}
};
void GameCLASS::Start()
{ bool exit_loop = false; int SceneNumber = 0;
do{
if( SCENE.NextScene == SceneNumber)
{
std::map<int,AnimCLASS> AnimMap;
std::vector <DrawableCLASS*> DrawableVec;
SCENE.SetUp(Audio,Mouse,SceneNumber,DrawableVec, AnimMap);
Run(DrawableVec, SceneNumber);
}
SceneNumber++;
if(SceneNumber>=NumberofScenes) SceneNumber=0;
if(SCENE.NextScene == 99) exit_loop=true;
}while(!exit_loop);
};
int main()
{
GameCLASS GAME;
GAME.SetUp();
GAME.Start();
return 0;
}