placed loadingscreen picture in json file of a world
This commit is contained in:
@@ -9,19 +9,16 @@
|
||||
#include "WorldHandler.h"
|
||||
|
||||
World::World(const std::string &fileName)
|
||||
{
|
||||
//ls.rise();
|
||||
ls.setTexture("loadingScreen_picture.png");
|
||||
ls.draw();
|
||||
{
|
||||
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);
|
||||
@@ -30,7 +27,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())
|
||||
@@ -45,6 +42,13 @@ World::World(const std::string &fileName)
|
||||
std::cout << "Invalid world file: enemies - " << fileName << "\n";
|
||||
if (v["crystals"].isNull())
|
||||
std::cout << "Invalid world file: crystals - " << fileName << "\n";
|
||||
|
||||
|
||||
if (!v["world"]["loadingscreen"].isNull())
|
||||
{
|
||||
ls.setTexture(v["world"]["loadingscreen"].asString());
|
||||
ls.draw();
|
||||
}
|
||||
|
||||
//Load object templates
|
||||
for (auto objt : v["world"]["object-templates"])
|
||||
@@ -55,28 +59,28 @@ World::World(const std::string &fileName)
|
||||
cancollide = objt["collision"].asBool();
|
||||
|
||||
objecttemplates.push_back(std::pair<int, std::pair<std::string, bool>>(objt["color"], std::pair<std::string, bool>(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"])
|
||||
@@ -109,7 +113,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;
|
||||
@@ -152,7 +156,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())
|
||||
@@ -196,7 +200,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;
|
||||
}
|
||||
@@ -206,7 +210,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())
|
||||
@@ -232,7 +236,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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 752 KiB After Width: | Height: | Size: 752 KiB |
@@ -2,6 +2,7 @@
|
||||
"world": {
|
||||
"heightmap": "worlds/rockHeightmap.png",
|
||||
"texture": "worlds/rockStone.png",
|
||||
"loadingscreen": "worlds/loadingScreen_picture.png",
|
||||
"skybox": "skyboxes/water/",
|
||||
"music": "WAVE/world1.wav",
|
||||
"object-templates": [
|
||||
|
||||
Reference in New Issue
Block a user