From 9192eb7371ae7bfc676c39bde70813c824b10374 Mon Sep 17 00:00:00 2001 From: Remco Date: Tue, 21 Jun 2016 23:38:33 +0200 Subject: [PATCH] see couting points of loading things --- LoadingScreen.cpp | 20 ++++++++++++++++---- LoadingScreen.h | 4 +++- World.cpp | 15 ++++++++++++++- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/LoadingScreen.cpp b/LoadingScreen.cpp index eedbb66..07f5354 100644 --- a/LoadingScreen.cpp +++ b/LoadingScreen.cpp @@ -2,9 +2,11 @@ #include #include "CrystalPoint.h" #include "Util.h" +#include LoadingScreen::LoadingScreen() { + points = 0; } @@ -33,14 +35,24 @@ void LoadingScreen::draw() glVertex2f(CrystalPoint::width, 0); glEnd(); - glColor4f(1.0f, 1.0f, 0.0f, 1.0f); + glColor4f(1.0f, 1.0f, 0.0f, 1.0f); - Util::glutBitmapString(loading, - CrystalPoint::width / 2 - Util::glutTextWidth(loading), - CrystalPoint::height / 2 - 7); + std::ostringstream oss; + + oss << loading << points << std::endl; + + Util::glutBitmapString(oss.str(), + CrystalPoint::width / 2 - Util::glutTextWidth(oss.str()), + CrystalPoint::height / 2 - 7); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); glutSwapBuffers(); } + +void LoadingScreen::rise() +{ + points++; + draw(); +} diff --git a/LoadingScreen.h b/LoadingScreen.h index 1bc47cc..4c79718 100644 --- a/LoadingScreen.h +++ b/LoadingScreen.h @@ -8,8 +8,10 @@ public: ~LoadingScreen(); void draw(); + void rise(); + int points; private: - const std::string loading = "Loading..."; + const std::string loading = "Loaded: "; }; diff --git a/World.cpp b/World.cpp index 1b0feba..d5c0150 100644 --- a/World.cpp +++ b/World.cpp @@ -10,14 +10,16 @@ World::World(const std::string &fileName) { - ls.draw(); + ls.rise(); nextworld = false; //Store player instance player = Player::getInstance(); + ls.rise(); //Create the interface interface = new Interface(); + ls.rise(); //Open world json file std::ifstream file(fileName); @@ -26,6 +28,7 @@ World::World(const std::string &fileName) json::Value v = json::readJson(file); file.close(); + ls.rise(); //Check file if(v["world"].isNull() || v["world"]["heightmap"].isNull() || v["world"]["skybox"].isNull()) @@ -50,23 +53,28 @@ World::World(const std::string &fileName) cancollide = objt["collision"].asBool(); objecttemplates.push_back(std::pair>(objt["color"], std::pair(objt["file"], cancollide))); + ls.rise(); } //Generate heightmap for this world heightmap = new HeightMap(v["world"]["heightmap"].asString(), this); + ls.rise(); //Load skybox skybox = new Skybox(15000.0f, v["world"]["skybox"].asString()); skybox->init(); + ls.rise(); //Map different texture to heightmap if available if(!v["world"]["texture"].isNull()) heightmap->SetTexture(v["world"]["texture"].asString()); + ls.rise(); //Set player starting position player->position.x = v["player"]["startposition"][0].asFloat(); player->position.z = v["player"]["startposition"][2].asFloat(); player->position.y = heightmap->GetHeight(player->position.x, player->position.z); + ls.rise(); //Load and place objects into world for (auto object : v["objects"]) @@ -99,6 +107,7 @@ World::World(const std::string &fileName) position.y = getHeight(position.x, position.z); entities.push_back(new LevelObject(object["file"].asString(), position, rotation, scale, hasCollision)); + ls.rise(); } maxEnemies = 0; @@ -141,6 +150,7 @@ World::World(const std::string &fileName) maxEnemies++; enemies.push_back(new Enemy(e["file"].asString(), e["music"].asString(), e["damage"].asFloat(), e["health"].asFloat(), position, rotation, scale)); + ls.rise(); } maxCrystals = 0; if (!v["crystal"].isNull()) @@ -184,6 +194,7 @@ World::World(const std::string &fileName) Crystal *c = new Crystal(filled, empty, position, rotation, scale); entities.push_back(c); + ls.rise(); } interface->maxCrystals = maxCrystals; } @@ -193,6 +204,7 @@ World::World(const std::string &fileName) { sound_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true); music = CrystalPoint::GetSoundSystem().GetSound(sound_id); + ls.rise(); } if (!v["portal"].isNull()) @@ -218,6 +230,7 @@ World::World(const std::string &fileName) portal = new Portal(v["portal"]["file"], pos, rot, scale); entities.push_back(portal); portal->maxCrystals = maxCrystals; + ls.rise(); } }