added levels snapshoting, quick debug loading, some level name refactoring

This commit is contained in:
Emil Kabirov 2018-06-10 00:29:55 +05:00
parent e25f4e3237
commit 74e947b6f3
30 changed files with 117 additions and 67 deletions

View File

@ -1,4 +1,6 @@
{ {
"useDebugBackgrounds": "true",
"TextureList": "TextureList":
{ {
"bg_1": "022259762-alien-world", "bg_1": "022259762-alien-world",

View File

@ -19,19 +19,19 @@
"scale": 0.1, "scale": 0.1,
"levels": [ "levels": [
{ {
"name": "level_1" "name": "level1"
}, },
{ {
"name": "level_2" "name": "level2"
}, },
{ {
"name": "level_3" "name": "level3"
}, },
{ {
"name": "level_4" "name": "level4"
}, },
{ {
"name": "level_5" "name": "level5"
} }
] ]
}, },
@ -45,10 +45,10 @@
"scale": 0.18, "scale": 0.18,
"levels": [ "levels": [
{ {
"name": "level_6" "name": "level6"
}, },
{ {
"name": "level_7" "name": "level7"
} }
] ]
}, },
@ -62,19 +62,19 @@
"scale": 0.12, "scale": 0.12,
"levels": [ "levels": [
{ {
"name": "level_8" "name": "level8"
}, },
{ {
"name": "level_9" "name": "level9"
}, },
{ {
"name": "level_10" "name": "level10"
}, },
{ {
"name": "level_11" "name": "level11"
}, },
{ {
"name": "level_12" "name": "level12"
} }
] ]
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 KiB

View File

@ -44,21 +44,22 @@ bool GalaxyMenu::InitGalaxyMenu(std::string config_json, float scale) {
star.scale = stars_pt.second.get<float>("scale", 0.0f); star.scale = stars_pt.second.get<float>("scale", 0.0f);
star.texture = stars_pt.second.get<std::string>("texture", "error"); star.texture = stars_pt.second.get<std::string>("texture", "error");
star.position = Eigen::Vector2f(stars_pt.second.get<float>("position.x_coord", 0.0f), stars_pt.second.get<float>("position.y_coord", 0.0f)); star.position = Eigen::Vector2f(stars_pt.second.get<float>("position.x_coord", 0.0f), stars_pt.second.get<float>("position.y_coord", 0.0f));
/*..Levels..*/ /*..Levels..*/
BOOST_FOREACH(auto levels_pt, stars_pt.second.get_child("levels")) { BOOST_FOREACH(auto levels_pt, stars_pt.second.get_child("levels")) {
std::string levelName = levels_pt.second.get<std::string>("name", "empty"); std::string levelName = levels_pt.second.get<std::string>("name", "empty");
star.selectionMenu.levels.push_back(levelName);
TGameLevel lvl; TGameLevel lvl;
lvl.FillWithFile(ST::PathToResources + "level" + levelName.substr(levelName.find("_") + 1) + ".txt"); lvl.FillWithFile(ST::PathToResources + levelName + ".txt");
star.selectionMenu.gameLevels.push_back(lvl);
star.selectionMenu.gameLevels.push_back(lvl);
} }
galax.Stars.push_back(star); galax.Stars.push_back(star);
} }
galaxies.push_back(galax); galaxies.push_back(galax);
} }
return true; return true;
} }
catch (boost::property_tree::ptree_error) { catch (boost::property_tree::ptree_error) {
@ -137,7 +138,7 @@ void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) {
for (int i = 0; i < galaxies.size(); i++) { for (int i = 0; i < galaxies.size(); i++) {
for (int j = 0; j < galaxies[i].Stars.size(); j++) { for (int j = 0; j < galaxies[i].Stars.size(); j++) {
float button_x_dim = ((1.f - (galaxies[i].Stars[j].selectionMenu.border_x_offset * 2 + (galaxies[i].Stars[j].selectionMenu.columns - 1)*galaxies[i].Stars[j].selectionMenu.buttons_offset)) / galaxies[i].Stars[j].selectionMenu.columns); // relative size float button_x_dim = ((1.f - (galaxies[i].Stars[j].selectionMenu.border_x_offset * 2 + (galaxies[i].Stars[j].selectionMenu.columns - 1)*galaxies[i].Stars[j].selectionMenu.buttons_offset)) / galaxies[i].Stars[j].selectionMenu.columns); // relative size
int rows_count = (int)ceil((float)galaxies[i].Stars[j].selectionMenu.levels.size() / (float)galaxies[i].Stars[j].selectionMenu.columns); int rows_count = (int)ceil((float)galaxies[i].Stars[j].selectionMenu.gameLevels.size() / (float)galaxies[i].Stars[j].selectionMenu.columns);
galaxies[i].Stars[j].selectionMenu.params = std::make_pair( galaxies[i].Stars[j].selectionMenu.params = std::make_pair(
Eigen::Vector2f( Eigen::Vector2f(
gameScreenCenter(0) + (galaxies[i].Stars[j].selectionMenu.offset(0) * gameScreenWidth / 2), gameScreenCenter(0) + (galaxies[i].Stars[j].selectionMenu.offset(0) * gameScreenWidth / 2),
@ -165,7 +166,7 @@ void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) {
// buttons // buttons
std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>> buttons_params; std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>> buttons_params;
std::vector<std::vector<GameLevelInterior>> interior_params; std::vector<std::vector<GameLevelInterior>> interior_params;
int levelsCount = galaxies[i].Stars[j].selectionMenu.levels.size(); int levelsCount = galaxies[i].Stars[j].selectionMenu.gameLevels.size();
buttons_params.resize(levelsCount); buttons_params.resize(levelsCount);
interior_params.resize(levelsCount); interior_params.resize(levelsCount);
for (int v = 0; v < interior_params.size(); v++) { for (int v = 0; v < interior_params.size(); v++) {
@ -426,13 +427,13 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) { if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) {
// OnTapDown->OnTapUp // OnTapDown->OnTapUp
int lvl = findLevelButtonByPos(lastTapPos); auto lvl = findLevelByButtonPos(lastTapPos);
if (lvl != -1) { if (lvl != nullptr) {
// then if level is available, load it // then if level is available, load it
starIndex = -1; starIndex = -1;
menuState = 0; menuState = 0;
planetHoverIndex = -1; planetHoverIndex = -1;
Application->GoFromMenuToGame(lvl-1); Application->GoFromMenuToGame(lvl);
} }
else if (!checkMenuBound(lastTapPos)) { else if (!checkMenuBound(lastTapPos)) {
// back to state 0 // back to state 0
@ -653,26 +654,32 @@ void GalaxyMenu::drawSelectionMenu(int index) {
); );
// buttons // buttons
for (int j = 0; j < galaxies[0].Stars[i].selectionMenu.buttons.size(); j++) { int j = 0;
std::string levelNum; for (auto &button : galaxies[0].Stars[i].selectionMenu.buttons)
size_t itr = galaxies[0].Stars[i].selectionMenu.levels[j].find("_"); {
for (int z = itr + 1; z < galaxies[0].Stars[i].selectionMenu.levels[j].size(); z++) {
levelNum += galaxies[0].Stars[i].selectionMenu.levels[j][z]; //std::string levelName = "shutterstock" + galaxies[0].Stars[i].selectionMenu.levels[j].substr(itr + 1);
}
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["shutterstock" + levelNum]); //glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList[levelName]);
std::string &levelName = galaxies[0].Stars[i].selectionMenu.gameLevels[j].levelName;
std::string levelPrerender = galaxies[0].Stars[i].selectionMenu.gameLevels[j].levelName + "_prerender";
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList[levelPrerender]);
SE::Renderer->DrawRect( SE::Renderer->DrawRect(
Eigen::Vector2f( Eigen::Vector2f(
galaxies[0].Stars[i].selectionMenu.buttons[j].first(0) - galaxies[0].Stars[i].selectionMenu.buttons[j].second(0) / 2, button.first(0) - button.second(0) / 2,
galaxies[0].Stars[i].selectionMenu.buttons[j].first(1) - galaxies[0].Stars[i].selectionMenu.buttons[j].second(1) / 2 button.first(1) - button.second(1) / 2
), ),
Eigen::Vector2f( Eigen::Vector2f(
galaxies[0].Stars[i].selectionMenu.buttons[j].first(0) + galaxies[0].Stars[i].selectionMenu.buttons[j].second(0) / 2, button.first(0) + button.second(0) / 2,
galaxies[0].Stars[i].selectionMenu.buttons[j].first(1) + galaxies[0].Stars[i].selectionMenu.buttons[j].second(1) / 2 button.first(1) + button.second(1) / 2
) )
); // DrawRect ); // DrawRect
/*..draw level interior..*/ /*..draw level interior..*/
drawLevelInterior(i,j); //drawLevelInterior(i,j);
/*std::list<std::pair<PairColorTexture, TTriangleList>>::iterator colorBlockIterator; /*std::list<std::pair<PairColorTexture, TTriangleList>>::iterator colorBlockIterator;
for (colorBlockIterator = galaxies[0].Stars[i].selectionMenu.levelInterior[j].BlockInstansingList.ColorBlockList.begin(); colorBlockIterator != galaxies[0].Stars[i].selectionMenu.levelInterior[j].BlockInstansingList.ColorBlockList.end(); ++colorBlockIterator) for (colorBlockIterator = galaxies[0].Stars[i].selectionMenu.levelInterior[j].BlockInstansingList.ColorBlockList.begin(); colorBlockIterator != galaxies[0].Stars[i].selectionMenu.levelInterior[j].BlockInstansingList.ColorBlockList.end(); ++colorBlockIterator)
@ -682,12 +689,14 @@ void GalaxyMenu::drawSelectionMenu(int index) {
Renderer->DrawTriangleList(colorBlockIterator->second); Renderer->DrawTriangleList(colorBlockIterator->second);
}*/ }*/
++j;
} }
} }
} }
int GalaxyMenu::findLevelButtonByPos(Eigen::Vector2f pos) { TGameLevel* GalaxyMenu::findLevelByButtonPos(Eigen::Vector2f pos) {
for (int i = 0; i < galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons.size(); i++) { for (int i = 0; i < galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons.size(); i++) {
float x_l = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(0) - galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(0)*0.5f; float x_l = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(0) - galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(0)*0.5f;
float x_r = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(0) + galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(0)*0.5f; float x_r = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(0) + galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(0)*0.5f;
@ -696,16 +705,11 @@ int GalaxyMenu::findLevelButtonByPos(Eigen::Vector2f pos) {
if (pos(0) >= x_l && pos(0) <= x_r) { if (pos(0) >= x_l && pos(0) <= x_r) {
if (pos(1) >= y_b && pos(1) <= y_t) { if (pos(1) >= y_b && pos(1) <= y_t) {
std::string lvlname = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.levels[i]; return &galaxies[galaxyIndex].Stars[starIndex].selectionMenu.gameLevels[i];
std::string lvlNum;
for (int z = lvlname.find("_")+1; z < lvlname.size(); z++) {
lvlNum+=lvlname[z];
}
return atoi(lvlNum.c_str());
} }
} }
} }
return -1; return nullptr;
} }
bool GalaxyMenu::checkMenuBound(Eigen::Vector2f pos) { bool GalaxyMenu::checkMenuBound(Eigen::Vector2f pos) {

View File

@ -79,7 +79,7 @@ private:
void takeInFocus(int g_index, int s_index = -1); void takeInFocus(int g_index, int s_index = -1);
int findGalaxyByPos(Eigen::Vector2f pos); int findGalaxyByPos(Eigen::Vector2f pos);
int findPlanetByPos(Eigen::Vector2f pos); int findPlanetByPos(Eigen::Vector2f pos);
int findLevelButtonByPos(Eigen::Vector2f pos); TGameLevel* findLevelByButtonPos(Eigen::Vector2f pos);
bool checkMenuBound(Eigen::Vector2f pos); bool checkMenuBound(Eigen::Vector2f pos);
/*..draw methodes..*/ /*..draw methodes..*/

View File

@ -11,7 +11,6 @@ class LevelSelection {
public: public:
/*..LEVELS..*/ /*..LEVELS..*/
std::vector<std::string> levels; // levels names, uses gameLevels init
/*..levels interior info..*/ /*..levels interior info..*/
std::vector<TGameLevel> gameLevels; std::vector<TGameLevel> gameLevels;
std::vector<std::vector<GameLevelInterior>> levelInterior; std::vector<std::vector<GameLevelInterior>> levelInterior;

21
game/gamecode.cpp Normal file → Executable file
View File

@ -15,6 +15,7 @@ const int CONST_LEVELSTATE_LOADING = 4;
const int CONST_LEVELSTATE_NODRAW = 5; const int CONST_LEVELSTATE_NODRAW = 5;
const int CONST_LEVELSTATE_FINISH_FREEZE = 6; const int CONST_LEVELSTATE_FINISH_FREEZE = 6;
const int CONST_LEVELSTATE_FINISHED = 7; const int CONST_LEVELSTATE_FINISHED = 7;
const int CONST_LEVELSTATE_SNAPSHOTTING = 8;
const float CONST_TIMER_LOADING = 150.f; const float CONST_TIMER_LOADING = 150.f;
@ -681,6 +682,9 @@ void TGameLevel::ReloadLevel()
void TGameLevel::FillWithFile(const std::string& filename) void TGameLevel::FillWithFile(const std::string& filename)
{ {
*SE::Console << "TGameLevel::FillWithFile"; *SE::Console << "TGameLevel::FillWithFile";
levelName = GetFileNameWithoutExt(filename);
LevelFileName = filename; LevelFileName = filename;
ReloadLevel(); ReloadLevel();
} }
@ -762,6 +766,21 @@ void TGameLevel::drawOutline() {
); );
} }
void TGameLevel::DrawSnapshot(const std::string& assignedShutterstock, const std::string& assignedSnapshotFrameBuffer)
{
BkgTexture = assignedShutterstock;
LevelScreenTexture = assignedShutterstock;
InitLevel();
int prevState = LevelState;
LevelState = CONST_LEVELSTATE_SNAPSHOTTING;
Draw();
LevelState = prevState;
prerenderedImage =
ResourceManager->FrameManager.GetFrameTextureCopy(assignedSnapshotFrameBuffer, levelName + "_prerender");
}
void TGameLevel::Draw() void TGameLevel::Draw()
{ {
*SE::Console << "TGameLevel::Draw"; *SE::Console << "TGameLevel::Draw";
@ -942,7 +961,7 @@ void TGameLevel::Draw()
} }
if (!pause) if (!pause && LevelState != CONST_LEVELSTATE_SNAPSHOTTING)
{ {
RenderUniform1f("Transparency", 1.f); RenderUniform1f("Transparency", 1.f);
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_BACK_BTN_TEXTURE]); glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_BACK_BTN_TEXTURE]);

5
game/gamecode.h Normal file → Executable file
View File

@ -129,8 +129,12 @@ protected:
std::string BkgTexture; std::string BkgTexture;
std::string LevelScreenTexture; std::string LevelScreenTexture;
std::string LevelFileName; std::string LevelFileName;
GLuint prerenderedImage;
Vector2f ReflectorPos; Vector2f ReflectorPos;
std::string levelName;
int LevelState; int LevelState;
bool PrevLevelStateIsStandby; bool PrevLevelStateIsStandby;
@ -199,6 +203,7 @@ public:
bool IsLoaded(); bool IsLoaded();
virtual void Draw(); virtual void Draw();
void DrawSnapshot(const std::string& assignedShutterstock, const std::string& assignedSnapshotFrameBuffer);
void SetPause(); void SetPause();
bool IsPaused(); bool IsPaused();

65
game/main_code.cpp Normal file → Executable file
View File

@ -282,19 +282,26 @@ void TMyApplication::LoadResources()
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock12.png", "shutterstock12")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock12.png", "shutterstock12"));
*/ */
#ifdef NDEBUG
bool useDebugBackgrounds = false;
#else
bool useDebugBackgrounds = Textures_pt.get<bool>("useDebugBackgrounds", false);
#endif
std::string backgroundPath = useDebugBackgrounds ? "level_background/debug/" : "level_background/";
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_1") + bg_ext, "shutterstock1")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_1") + bg_ext, "shutterstock1"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_2") + bg_ext, "shutterstock2")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_2") + bg_ext, "shutterstock2"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_3") + bg_ext, "shutterstock3")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_3") + bg_ext, "shutterstock3"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_4") + bg_ext, "shutterstock4")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_4") + bg_ext, "shutterstock4"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_5") + bg_ext, "shutterstock5")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_5") + bg_ext, "shutterstock5"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_6") + bg_ext, "shutterstock6")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_6") + bg_ext, "shutterstock6"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_7") + bg_ext, "shutterstock7")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_7") + bg_ext, "shutterstock7"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_8") + bg_ext, "shutterstock8")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_8") + bg_ext, "shutterstock8"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_9") + bg_ext, "shutterstock9")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_9") + bg_ext, "shutterstock9"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_10") + bg_ext, "shutterstock10")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_10") + bg_ext, "shutterstock10"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_11") + bg_ext, "shutterstock11")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_11") + bg_ext, "shutterstock11"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("level_background/" + Textures_pt.get<std::string>("TextureList.bg_12") + bg_ext, "shutterstock12")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>(backgroundPath + Textures_pt.get<std::string>("TextureList.bg_12") + bg_ext, "shutterstock12"));
/*..galaxies and stars/planets Init..*/ // tmp /*..galaxies and stars/planets Init..*/ // tmp
std::vector<int> galaxies; std::vector<int> galaxies;
@ -436,6 +443,21 @@ void TMyApplication::InnerUpdate(size_t dt)
} }
else else
{ {
Renderer->SwitchToFrameBuffer("LevelBuffer");
int levelIndex = 1;
for (auto &star : Menu.GalaxMenu.galaxies[0].Stars)
{
for (auto &level : star.selectionMenu.gameLevels)
{
level.DrawSnapshot("shutterstock" + std::to_string(levelIndex++), "LevelBuffer");
}
}
Renderer->SwitchToScreen();
GameState = CONST_GAMESTATE_MENU; GameState = CONST_GAMESTATE_MENU;
ApplySignalsToMenu(); ApplySignalsToMenu();
OnDrawSignal.disconnect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading))); OnDrawSignal.disconnect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
@ -447,7 +469,7 @@ void TMyApplication::InnerUpdate(size_t dt)
else if (GameState == CONST_GAMESTATE_LEVEL) else if (GameState == CONST_GAMESTATE_LEVEL)
{ {
*SE::Console << "3CONST_GAMESTATE_LEVEL"; *SE::Console << "3CONST_GAMESTATE_LEVEL";
GameLevel.Update(dt); GameLevel->Update(dt);
EffectsUpdate(dt); EffectsUpdate(dt);
} }
else if (GameState == CONST_GAMESTATE_MENU) else if (GameState == CONST_GAMESTATE_MENU)
@ -459,8 +481,8 @@ void TMyApplication::InnerUpdate(size_t dt)
else if (GameState == CONST_GAMESTATE_FROM_MENU_TO_LEVEL) else if (GameState == CONST_GAMESTATE_FROM_MENU_TO_LEVEL)
{ {
*SE::Console << "5CONST_GAMESTATE_FROM_MENU_TO_LEVEL"; *SE::Console << "5CONST_GAMESTATE_FROM_MENU_TO_LEVEL";
GameLevel.Update(dt); GameLevel->Update(dt);
if (GameLevel.IsLoaded()) if (GameLevel->IsLoaded())
{ {
//*SE::Console << "5CONST_GAMESTATE_FROM_MENU_TO_LEVEL"; //*SE::Console << "5CONST_GAMESTATE_FROM_MENU_TO_LEVEL";
GameState = CONST_GAMESTATE_LEVEL; GameState = CONST_GAMESTATE_LEVEL;
@ -505,16 +527,15 @@ void TMyApplication::InnerUpdate(size_t dt)
} }
void TMyApplication::GoFromMenuToGame(int level) void TMyApplication::GoFromMenuToGame(TGameLevel* level)
{ {
//#ifndef TARGET_IOS //#ifndef TARGET_IOS
// ResourceManager->SoundManager.PlayMusicLooped("level1ogg.ogg"); // ResourceManager->SoundManager.PlayMusicLooped("level1ogg.ogg");
//#endif //#endif
GameLevel = level;
GameLevel.FillWithFile(ST::PathToResources + "level"+tostr(level+1)+".txt"); GameLevel->SetLoading(level->BkgTexture, level->LevelScreenTexture);
GameLevel.SetLoading("shutterstock" + tostr(level+1), "shutterstock" + tostr(level + 1));
GameState = CONST_GAMESTATE_FROM_MENU_TO_LEVEL; GameState = CONST_GAMESTATE_FROM_MENU_TO_LEVEL;
OnDrawSignal.connect(1, boost::bind(&TGameLevel::Draw, boost::ref(GameLevel))); OnDrawSignal.connect(1, boost::bind(&TGameLevel::Draw, boost::ref(*GameLevel)));
DisapplySignalsToMenu(); DisapplySignalsToMenu();
@ -709,8 +730,8 @@ void TMyApplication::SetButtonsAction () {
auto backBtn = ResourceManager->newGuiManager.findWidgetByName("backButton"); auto backBtn = ResourceManager->newGuiManager.findWidgetByName("backButton");
if (backBtn) { if (backBtn) {
backBtn->onMouseDownSignal.connect([this, backBtn](Vector2f pos, int touchNumber) { backBtn->onMouseDownSignal.connect([this, backBtn](Vector2f pos, int touchNumber) {
this->GameLevel.SetPause(); this->GameLevel->SetPause();
this->GameLevel.PrevLevelStateIsStandby = true; this->GameLevel->PrevLevelStateIsStandby = true;
}); });
} }
} }

4
game/main_code.h Normal file → Executable file
View File

@ -98,7 +98,7 @@ protected:
ParticleEffect lvlFirework; // Level finished effect ParticleEffect lvlFirework; // Level finished effect
TGameMenu Menu; TGameMenu Menu;
TGameLevel GameLevel; TGameLevel* GameLevel;
TGameCredits GameCredits; TGameCredits GameCredits;
TGameLoading GameLoading; TGameLoading GameLoading;
@ -139,7 +139,7 @@ public:
virtual void InnerUpdate(size_t dt); virtual void InnerUpdate(size_t dt);
void GoFromMenuToGame(int level); void GoFromMenuToGame(TGameLevel* level);
void GoFromGameToMenu(); void GoFromGameToMenu();
void GoFromMenuToCredits(); void GoFromMenuToCredits();
void GoFromCreditsToMenu(); void GoFromCreditsToMenu();