placed loadingscreen picture in json file of a world
This commit is contained in:
@@ -9,19 +9,16 @@
|
|||||||
#include "WorldHandler.h"
|
#include "WorldHandler.h"
|
||||||
|
|
||||||
World::World(const std::string &fileName)
|
World::World(const std::string &fileName)
|
||||||
{
|
{
|
||||||
//ls.rise();
|
|
||||||
ls.setTexture("loadingScreen_picture.png");
|
|
||||||
ls.draw();
|
|
||||||
nextworld = false;
|
nextworld = false;
|
||||||
|
|
||||||
//Store player instance
|
//Store player instance
|
||||||
player = Player::getInstance();
|
player = Player::getInstance();
|
||||||
//ls.rise();
|
|
||||||
|
|
||||||
//Create the interface
|
//Create the interface
|
||||||
interface = new Interface();
|
interface = new Interface();
|
||||||
//ls.rise();
|
|
||||||
|
|
||||||
//Open world json file
|
//Open world json file
|
||||||
std::ifstream file(fileName);
|
std::ifstream file(fileName);
|
||||||
@@ -30,7 +27,7 @@ World::World(const std::string &fileName)
|
|||||||
|
|
||||||
json::Value v = json::readJson(file);
|
json::Value v = json::readJson(file);
|
||||||
file.close();
|
file.close();
|
||||||
//ls.rise();
|
|
||||||
|
|
||||||
//Check file
|
//Check file
|
||||||
if(v["world"].isNull() || v["world"]["heightmap"].isNull() || v["world"]["skybox"].isNull())
|
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";
|
std::cout << "Invalid world file: enemies - " << fileName << "\n";
|
||||||
if (v["crystals"].isNull())
|
if (v["crystals"].isNull())
|
||||||
std::cout << "Invalid world file: crystals - " << fileName << "\n";
|
std::cout << "Invalid world file: crystals - " << fileName << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
if (!v["world"]["loadingscreen"].isNull())
|
||||||
|
{
|
||||||
|
ls.setTexture(v["world"]["loadingscreen"].asString());
|
||||||
|
ls.draw();
|
||||||
|
}
|
||||||
|
|
||||||
//Load object templates
|
//Load object templates
|
||||||
for (auto objt : v["world"]["object-templates"])
|
for (auto objt : v["world"]["object-templates"])
|
||||||
@@ -55,28 +59,28 @@ World::World(const std::string &fileName)
|
|||||||
cancollide = objt["collision"].asBool();
|
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)));
|
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
|
//Generate heightmap for this world
|
||||||
heightmap = new HeightMap(v["world"]["heightmap"].asString(), this);
|
heightmap = new HeightMap(v["world"]["heightmap"].asString(), this);
|
||||||
//ls.rise();
|
|
||||||
|
|
||||||
//Load skybox
|
//Load skybox
|
||||||
skybox = new Skybox(15000.0f, v["world"]["skybox"].asString());
|
skybox = new Skybox(15000.0f, v["world"]["skybox"].asString());
|
||||||
skybox->init();
|
skybox->init();
|
||||||
//ls.rise();
|
|
||||||
|
|
||||||
//Map different texture to heightmap if available
|
//Map different texture to heightmap if available
|
||||||
if(!v["world"]["texture"].isNull())
|
if(!v["world"]["texture"].isNull())
|
||||||
heightmap->SetTexture(v["world"]["texture"].asString());
|
heightmap->SetTexture(v["world"]["texture"].asString());
|
||||||
//ls.rise();
|
|
||||||
|
|
||||||
//Set player starting position
|
//Set player starting position
|
||||||
player->position.x = v["player"]["startposition"][0].asFloat();
|
player->position.x = v["player"]["startposition"][0].asFloat();
|
||||||
player->position.z = v["player"]["startposition"][2].asFloat();
|
player->position.z = v["player"]["startposition"][2].asFloat();
|
||||||
player->position.y = heightmap->GetHeight(player->position.x, player->position.z);
|
player->position.y = heightmap->GetHeight(player->position.x, player->position.z);
|
||||||
//ls.rise();
|
|
||||||
|
|
||||||
//Load and place objects into world
|
//Load and place objects into world
|
||||||
for (auto object : v["objects"])
|
for (auto object : v["objects"])
|
||||||
@@ -109,7 +113,7 @@ World::World(const std::string &fileName)
|
|||||||
position.y = getHeight(position.x, position.z);
|
position.y = getHeight(position.x, position.z);
|
||||||
|
|
||||||
entities.push_back(new LevelObject(object["file"].asString(), position, rotation, scale, hasCollision));
|
entities.push_back(new LevelObject(object["file"].asString(), position, rotation, scale, hasCollision));
|
||||||
//ls.rise();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
maxEnemies = 0;
|
maxEnemies = 0;
|
||||||
@@ -152,7 +156,7 @@ World::World(const std::string &fileName)
|
|||||||
|
|
||||||
maxEnemies++;
|
maxEnemies++;
|
||||||
enemies.push_back(new Enemy(e["file"].asString(), e["music"].asString(), e["damage"].asFloat(), e["health"].asFloat(), position, rotation, scale));
|
enemies.push_back(new Enemy(e["file"].asString(), e["music"].asString(), e["damage"].asFloat(), e["health"].asFloat(), position, rotation, scale));
|
||||||
//ls.rise();
|
|
||||||
}
|
}
|
||||||
maxCrystals = 0;
|
maxCrystals = 0;
|
||||||
if (!v["crystal"].isNull())
|
if (!v["crystal"].isNull())
|
||||||
@@ -196,7 +200,7 @@ World::World(const std::string &fileName)
|
|||||||
Crystal *c = new Crystal(filled, empty, position, rotation, scale);
|
Crystal *c = new Crystal(filled, empty, position, rotation, scale);
|
||||||
|
|
||||||
entities.push_back(c);
|
entities.push_back(c);
|
||||||
//ls.rise();
|
|
||||||
}
|
}
|
||||||
interface->maxCrystals = maxCrystals;
|
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);
|
sound_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true);
|
||||||
music = CrystalPoint::GetSoundSystem().GetSound(sound_id);
|
music = CrystalPoint::GetSoundSystem().GetSound(sound_id);
|
||||||
//ls.rise();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!v["portal"].isNull())
|
if (!v["portal"].isNull())
|
||||||
@@ -232,7 +236,7 @@ World::World(const std::string &fileName)
|
|||||||
portal = new Portal(v["portal"]["file"], pos, rot, scale);
|
portal = new Portal(v["portal"]["file"], pos, rot, scale);
|
||||||
entities.push_back(portal);
|
entities.push_back(portal);
|
||||||
portal->maxCrystals = maxCrystals;
|
portal->maxCrystals = maxCrystals;
|
||||||
//ls.rise();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 752 KiB After Width: | Height: | Size: 752 KiB |
@@ -2,6 +2,7 @@
|
|||||||
"world": {
|
"world": {
|
||||||
"heightmap": "worlds/rockHeightmap.png",
|
"heightmap": "worlds/rockHeightmap.png",
|
||||||
"texture": "worlds/rockStone.png",
|
"texture": "worlds/rockStone.png",
|
||||||
|
"loadingscreen": "worlds/loadingScreen_picture.png",
|
||||||
"skybox": "skyboxes/water/",
|
"skybox": "skyboxes/water/",
|
||||||
"music": "WAVE/world1.wav",
|
"music": "WAVE/world1.wav",
|
||||||
"object-templates": [
|
"object-templates": [
|
||||||
|
|||||||
Reference in New Issue
Block a user