changed filePath to levelNum
This commit is contained in:
parent
1ab7783d41
commit
f218a141fa
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@ -7,6 +7,8 @@ Application::Application() {
|
||||
|
||||
void Application::init()
|
||||
{
|
||||
// choose Level TODO: Choose this in a menu
|
||||
this->level = Level("0");
|
||||
// Don't change this!
|
||||
ignoredMouseUpdates = 0;
|
||||
cameraLock = true;
|
||||
|
31
level.cc
31
level.cc
@ -2,9 +2,9 @@
|
||||
|
||||
|
||||
|
||||
Level::Level(std::string filePath){
|
||||
this->filePath = filePath;
|
||||
this->terrain = Terrain(filePath + "/terrain");
|
||||
Level::Level(std::string levelNum){
|
||||
this->levelNum = levelNum;
|
||||
this->terrain = Terrain(levelNum);
|
||||
skydomeSize = 50.0f;
|
||||
}
|
||||
|
||||
@ -25,6 +25,31 @@ void Level::load() {
|
||||
// currently hard coded should later read this stuff out of a file
|
||||
this->camera = Camera(glm::vec2(-0.8f, 0.0f), 3.0f);
|
||||
|
||||
/*Loading Objects via xml:
|
||||
XMLDocument* doc = new XMLDocument();
|
||||
const char* xmlFile = ("../Levels/ObjectSetups/Level" + levelNum + ".xml").c_str();
|
||||
doc->LoadFile(xmlFile);
|
||||
if (doc->ErrorID()!=0){
|
||||
printf("Could not open ObjectSetupXml!\n");
|
||||
exit(-1);
|
||||
}
|
||||
XMLDocument* compositions = new XMLDocument();
|
||||
const char* compositionsFile = "../Levels/ObjectSetups/Compositions.xml";
|
||||
compositions->LoadFile(compositionsFile);
|
||||
if (compositions->ErrorID()!=0){
|
||||
printf("Could not open Compositions!\n");
|
||||
exit(-1);
|
||||
}
|
||||
XMLElement* thisComposition = compositions->FirstChildElement("composition");
|
||||
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement()){
|
||||
int thisType;
|
||||
thisComposition->QueryIntAttribute("typeID", &thisType);
|
||||
if(thisType == type){
|
||||
...
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//add player
|
||||
Model model = Model("MarbleSmooth.obj", 0.75f);
|
||||
Material material = Material("marbleTexture_small.png", 0.1f, 0.5f, 0.5f, 3.0f);
|
||||
|
5
level.hh
5
level.hh
@ -9,10 +9,11 @@
|
||||
#include "material.hh"
|
||||
#include "camera.hh"
|
||||
#include "physics.hh"
|
||||
#include "converter/tinyxml2.hh"
|
||||
|
||||
class Level {
|
||||
public:
|
||||
Level(std::string filePath);
|
||||
Level(std::string levelNum);
|
||||
Level();
|
||||
~Level();
|
||||
void load();
|
||||
@ -27,7 +28,7 @@ class Level {
|
||||
glm::vec4 getFogColor();
|
||||
void setSkydomeSize(float size);
|
||||
private:
|
||||
std::string filePath;
|
||||
std::string levelNum;
|
||||
std::vector<Object*> objects;
|
||||
std::vector<Object*> physicObjects;
|
||||
std::vector<Light> lights;
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "terrain.hh"
|
||||
#include "lodepng.h"
|
||||
|
||||
Terrain::Terrain(std::string filePath){
|
||||
this->filePath = filePath;
|
||||
Terrain::Terrain(std::string levelNum){
|
||||
this->levelNum = levelNum;
|
||||
}
|
||||
|
||||
Terrain::Terrain(){
|
||||
@ -13,10 +13,8 @@ Terrain::~Terrain() {
|
||||
|
||||
|
||||
void Terrain::load() {
|
||||
filePath = "../Levels/heightmapLvlTest.png"; //TODO remove this, its only for testing
|
||||
|
||||
std::vector<unsigned char> image; //the raw pixels
|
||||
unsigned error = lodepng::decode(image, heightmapWidth, heightmapHeight, filePath);
|
||||
unsigned error = lodepng::decode(image, heightmapWidth, heightmapHeight, "../Levels/heightmapLvl" + levelNum + ".png");
|
||||
if (error) {
|
||||
std::cout << "decoder error " << error << ": " << lodepng_error_text(error) << std::endl;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "model.hh"
|
||||
class Terrain {
|
||||
public:
|
||||
Terrain(std::string filePath);
|
||||
Terrain(std::string levelNum);
|
||||
Terrain();
|
||||
~Terrain();
|
||||
void load();
|
||||
@ -19,7 +19,7 @@ class Terrain {
|
||||
|
||||
private:
|
||||
Material material;
|
||||
std::string filePath;
|
||||
std::string levelNum;
|
||||
unsigned int heightmapHeight, heightmapWidth;
|
||||
float** heightmap; //can be accessed like 'float[][]'
|
||||
bool heightmapChanged;
|
||||
|
Loading…
Reference in New Issue
Block a user