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()
|
void Application::init()
|
||||||
{
|
{
|
||||||
|
// choose Level TODO: Choose this in a menu
|
||||||
|
this->level = Level("0");
|
||||||
// Don't change this!
|
// Don't change this!
|
||||||
ignoredMouseUpdates = 0;
|
ignoredMouseUpdates = 0;
|
||||||
cameraLock = true;
|
cameraLock = true;
|
||||||
|
31
level.cc
31
level.cc
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Level::Level(std::string filePath){
|
Level::Level(std::string levelNum){
|
||||||
this->filePath = filePath;
|
this->levelNum = levelNum;
|
||||||
this->terrain = Terrain(filePath + "/terrain");
|
this->terrain = Terrain(levelNum);
|
||||||
skydomeSize = 50.0f;
|
skydomeSize = 50.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +25,31 @@ void Level::load() {
|
|||||||
// currently hard coded should later read this stuff out of a file
|
// currently hard coded should later read this stuff out of a file
|
||||||
this->camera = Camera(glm::vec2(-0.8f, 0.0f), 3.0f);
|
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
|
//add player
|
||||||
Model model = Model("MarbleSmooth.obj", 0.75f);
|
Model model = Model("MarbleSmooth.obj", 0.75f);
|
||||||
Material material = Material("marbleTexture_small.png", 0.1f, 0.5f, 0.5f, 3.0f);
|
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 "material.hh"
|
||||||
#include "camera.hh"
|
#include "camera.hh"
|
||||||
#include "physics.hh"
|
#include "physics.hh"
|
||||||
|
#include "converter/tinyxml2.hh"
|
||||||
|
|
||||||
class Level {
|
class Level {
|
||||||
public:
|
public:
|
||||||
Level(std::string filePath);
|
Level(std::string levelNum);
|
||||||
Level();
|
Level();
|
||||||
~Level();
|
~Level();
|
||||||
void load();
|
void load();
|
||||||
@ -27,7 +28,7 @@ class Level {
|
|||||||
glm::vec4 getFogColor();
|
glm::vec4 getFogColor();
|
||||||
void setSkydomeSize(float size);
|
void setSkydomeSize(float size);
|
||||||
private:
|
private:
|
||||||
std::string filePath;
|
std::string levelNum;
|
||||||
std::vector<Object*> objects;
|
std::vector<Object*> objects;
|
||||||
std::vector<Object*> physicObjects;
|
std::vector<Object*> physicObjects;
|
||||||
std::vector<Light> lights;
|
std::vector<Light> lights;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "terrain.hh"
|
#include "terrain.hh"
|
||||||
#include "lodepng.h"
|
#include "lodepng.h"
|
||||||
|
|
||||||
Terrain::Terrain(std::string filePath){
|
Terrain::Terrain(std::string levelNum){
|
||||||
this->filePath = filePath;
|
this->levelNum = levelNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
Terrain::Terrain(){
|
Terrain::Terrain(){
|
||||||
@ -13,10 +13,8 @@ Terrain::~Terrain() {
|
|||||||
|
|
||||||
|
|
||||||
void Terrain::load() {
|
void Terrain::load() {
|
||||||
filePath = "../Levels/heightmapLvlTest.png"; //TODO remove this, its only for testing
|
|
||||||
|
|
||||||
std::vector<unsigned char> image; //the raw pixels
|
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) {
|
if (error) {
|
||||||
std::cout << "decoder error " << error << ": " << lodepng_error_text(error) << std::endl;
|
std::cout << "decoder error " << error << ": " << lodepng_error_text(error) << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "model.hh"
|
#include "model.hh"
|
||||||
class Terrain {
|
class Terrain {
|
||||||
public:
|
public:
|
||||||
Terrain(std::string filePath);
|
Terrain(std::string levelNum);
|
||||||
Terrain();
|
Terrain();
|
||||||
~Terrain();
|
~Terrain();
|
||||||
void load();
|
void load();
|
||||||
@ -19,7 +19,7 @@ class Terrain {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Material material;
|
Material material;
|
||||||
std::string filePath;
|
std::string levelNum;
|
||||||
unsigned int heightmapHeight, heightmapWidth;
|
unsigned int heightmapHeight, heightmapWidth;
|
||||||
float** heightmap; //can be accessed like 'float[][]'
|
float** heightmap; //can be accessed like 'float[][]'
|
||||||
bool heightmapChanged;
|
bool heightmapChanged;
|
||||||
|
Loading…
Reference in New Issue
Block a user