Merge branch 'developer' into johan
# Conflicts: # World.cpp # worlds/world1.json
This commit is contained in:
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
/workspace.xml
|
||||||
|
/vcs.xml
|
||||||
|
/modules.xml
|
||||||
|
/misc.xml
|
||||||
|
/encodings.xml
|
||||||
|
/CrystalPoint.iml
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
project(CrystalPoint)
|
||||||
|
|
||||||
|
file(GLOB SOURCE_FILES
|
||||||
|
"*.h"
|
||||||
|
"*.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(CrystalPoint ${SOURCE_FILES})
|
||||||
|
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
find_package(GLUT REQUIRED)
|
||||||
|
include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} )
|
||||||
|
target_link_libraries(CrystalPoint ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} )
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall ")
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
#include "CrystalJohan.h"
|
#include "CrystalJohan.h"
|
||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
|
|
||||||
void CrystalJohan::init()
|
void CrystalJohan::init()
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class World;
|
class World;
|
||||||
#include "vector.h"
|
#include "Vector.h"
|
||||||
|
|
||||||
class KeyboardState
|
class KeyboardState
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
#include "cmath"
|
||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
|
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "CrystalJohan.h"
|
#include "CrystalJohan.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "vector.h"
|
#include "Vector.h"
|
||||||
|
|
||||||
void configureOpenGL(void);
|
void configureOpenGL(void);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "vector.h"
|
#include "Vector.h"
|
||||||
|
|
||||||
class Model
|
class Model
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "Singleton.h"
|
#include "Singleton.h"
|
||||||
|
|
||||||
#include "vector.h"
|
#include "Vector.h"
|
||||||
|
|
||||||
class Model;
|
class Model;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -25,7 +25,7 @@ Vec3f::Vec3f()
|
|||||||
this->y = 0;
|
this->y = 0;
|
||||||
this->z = 0;
|
this->z = 0;
|
||||||
}
|
}
|
||||||
Vec3f::Vec3f(Vec3f &other)
|
Vec3f::Vec3f(const Vec3f &other)
|
||||||
{
|
{
|
||||||
this->x = other.x;
|
this->x = other.x;
|
||||||
this->y = other.y;
|
this->y = other.y;
|
||||||
@@ -75,7 +75,7 @@ Vec2f::Vec2f()
|
|||||||
this->x = 0;
|
this->x = 0;
|
||||||
this->y = 0;
|
this->y = 0;
|
||||||
}
|
}
|
||||||
Vec2f::Vec2f(Vec2f &other)
|
Vec2f::Vec2f(const Vec2f &other)
|
||||||
{
|
{
|
||||||
this->x = other.x;
|
this->x = other.x;
|
||||||
this->y = other.y;
|
this->y = other.y;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public:
|
|||||||
float v[3];
|
float v[3];
|
||||||
};
|
};
|
||||||
Vec3f();
|
Vec3f();
|
||||||
Vec3f(Vec3f &other);
|
Vec3f(const Vec3f &other);
|
||||||
Vec3f(float x, float y, float z);
|
Vec3f(float x, float y, float z);
|
||||||
float Length();
|
float Length();
|
||||||
float Distance(const Vec3f &);
|
float Distance(const Vec3f &);
|
||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
};
|
};
|
||||||
Vec2f();
|
Vec2f();
|
||||||
Vec2f(float x, float y);
|
Vec2f(float x, float y);
|
||||||
Vec2f(Vec2f &other);
|
Vec2f(const Vec2f &other);
|
||||||
float& operator [](int);
|
float& operator [](int);
|
||||||
Vec2f operator + (const Vec2f &other);
|
Vec2f operator + (const Vec2f &other);
|
||||||
float length();
|
float length();
|
||||||
|
|||||||
@@ -4,19 +4,20 @@
|
|||||||
#include "LevelObject.h"
|
#include "LevelObject.h"
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
World::World() : player(Player::getInstance())
|
World::World() : player(Player::getInstance())
|
||||||
{
|
{
|
||||||
json::Value v = json::readJson(std::ifstream("worlds/world1.json"));
|
|
||||||
|
|
||||||
if (!v["player"]["startposition"].isNull())
|
std::ifstream file("worlds/world1.json");
|
||||||
{
|
if(!file.is_open())
|
||||||
player.position.x = v["player"]["startposition"][0];
|
std::cout<<"Uhoh, can't open file\n";
|
||||||
player.position.y = v["player"]["startposition"][1];
|
json::Value v = json::readJson(file);
|
||||||
player.position.z = v["player"]["startposition"][2];
|
std::cout<<v;
|
||||||
}
|
file.close();
|
||||||
|
player.position.x = v["player"]["startposition"][0];
|
||||||
|
player.position.y = v["player"]["startposition"][1];
|
||||||
|
player.position.z = v["player"]["startposition"][2];
|
||||||
|
|
||||||
|
|
||||||
for (auto object : v["objects"])
|
for (auto object : v["objects"])
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ namespace json
|
|||||||
Value();
|
Value();
|
||||||
Value(Type type);
|
Value(Type type);
|
||||||
Value(int value);
|
Value(int value);
|
||||||
Value(__int64 value);
|
|
||||||
Value(float value);
|
Value(float value);
|
||||||
Value(bool value);
|
Value(bool value);
|
||||||
Value(const std::string &value);
|
Value(const std::string &value);
|
||||||
@@ -50,24 +49,24 @@ namespace json
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline operator int() const { return asInt(); }
|
inline operator int() const { return asInt(); }
|
||||||
inline operator float() const { return asFloat(); }
|
inline operator float() const { return asFloat(); }
|
||||||
inline operator bool() const { return asBool(); }
|
inline operator bool() const { return asBool(); }
|
||||||
inline operator const std::string&() const { return asString(); }
|
inline operator const std::string&() const { return asString(); }
|
||||||
|
|
||||||
|
|
||||||
inline int asInt() const { assert(type == Type::intValue); return value.intValue; }
|
inline int asInt() const { assert(type == Type::intValue); return value.intValue; }
|
||||||
inline float asFloat() const { assert(type == Type::floatValue || type == Type::intValue); return type == Type::floatValue ? value.floatValue : value.intValue; }
|
inline float asFloat() const { assert(type == Type::floatValue || type == Type::intValue); return type == Type::floatValue ? value.floatValue : value.intValue; }
|
||||||
inline bool asBool() const { assert(type == Type::boolValue); return value.boolValue; }
|
inline bool asBool() const { assert(type == Type::boolValue); return value.boolValue; }
|
||||||
inline const std::string& asString() const { assert(type == Type::stringValue); return *value.stringValue; }
|
inline const std::string& asString() const { assert(type == Type::stringValue); return *value.stringValue; }
|
||||||
inline bool isNull() const { return type == Type::nullValue; }
|
inline bool isNull() const { return type == Type::nullValue; }
|
||||||
inline bool isString() const { return type == Type::stringValue; }
|
inline bool isString() const { return type == Type::stringValue; }
|
||||||
inline bool isInt() const { return type == Type::intValue; }
|
inline bool isInt() const { return type == Type::intValue; }
|
||||||
inline bool isBool() const { return type == Type::boolValue; }
|
inline bool isBool() const { return type == Type::boolValue; }
|
||||||
inline bool isFloat() const { return type == Type::floatValue; }
|
inline bool isFloat() const { return type == Type::floatValue; }
|
||||||
inline bool isObject() const { return type == Type::objectValue; }
|
inline bool isObject() const { return type == Type::objectValue; }
|
||||||
inline bool isArray() const { return type == Type::arrayValue; }
|
inline bool isArray() const { return type == Type::arrayValue; }
|
||||||
inline bool isMember(const std::string &name) const { if (type != Type::objectValue) return false; return value.objectValue->find(name) != value.objectValue->end(); }
|
inline bool isMember(const std::string &name) const { assert(type == Type::objectValue); return value.objectValue->find(name) != value.objectValue->end(); }
|
||||||
//array/object
|
//array/object
|
||||||
virtual size_t size() const;
|
virtual size_t size() const;
|
||||||
//array
|
//array
|
||||||
@@ -83,8 +82,6 @@ namespace json
|
|||||||
virtual Value& operator [] (const std::string &key) const;
|
virtual Value& operator [] (const std::string &key) const;
|
||||||
virtual Value& operator [] (const char* key) const;
|
virtual Value& operator [] (const char* key) const;
|
||||||
|
|
||||||
virtual const Value& get(const char* key, const Value& default) const;
|
|
||||||
|
|
||||||
virtual bool operator == (const std::string &other) { return asString() == other; }
|
virtual bool operator == (const std::string &other) { return asString() == other; }
|
||||||
virtual bool operator == (const int other) { return asInt() == other; }
|
virtual bool operator == (const int other) { return asInt() == other; }
|
||||||
virtual bool operator == (const float other) { return asFloat() == other; }
|
virtual bool operator == (const float other) { return asFloat() == other; }
|
||||||
@@ -93,9 +90,6 @@ namespace json
|
|||||||
std::ostream& prettyPrint(std::ostream& stream, json::Value& printConfig = null, int level = 0) const;
|
std::ostream& prettyPrint(std::ostream& stream, json::Value& printConfig = null, int level = 0) const;
|
||||||
|
|
||||||
class Iterator;
|
class Iterator;
|
||||||
private:
|
|
||||||
|
|
||||||
public:
|
|
||||||
Iterator begin() const;
|
Iterator begin() const;
|
||||||
Iterator end() const;
|
Iterator end() const;
|
||||||
};
|
};
|
||||||
@@ -125,8 +119,6 @@ namespace json
|
|||||||
Value readJson(const std::string &data);
|
Value readJson(const std::string &data);
|
||||||
Value readJson(std::istream &stream);
|
Value readJson(std::istream &stream);
|
||||||
std::ostream &operator << (std::ostream &stream, const Value& value); //serializes json data
|
std::ostream &operator << (std::ostream &stream, const Value& value); //serializes json data
|
||||||
std::string &operator << (std::string &stream, const Value& value); //serializes json data
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user