aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/common.hpp52
-rw-r--r--include/coolarray.hpp2
-rw-r--r--include/window.hpp3
-rw-r--r--include/world.hpp55
4 files changed, 39 insertions, 73 deletions
diff --git a/include/common.hpp b/include/common.hpp
index 15442a7..69e6a11 100644
--- a/include/common.hpp
+++ b/include/common.hpp
@@ -71,25 +71,15 @@ typedef ivec2 dim2;
/**
* Creates a coordinate out of floating point integers.
*/
-class vec2 {
-public:
+struct vec2 {
float x; /**< The x coordinate */
float y; /**< The y coordinate */
/**
- * Constructs an empty vec2.
- */
- vec2(){
- x = y = 0.0f;
- }
-
- /**
* Constructs a vec2 with the specified coordinates.
*/
- vec2(float _x, float _y) {
- x = _x;
- y = _y;
- }
+ vec2(float _x = 0.0f, float _y = 0.0f)
+ : x(_x), y(_y) {}
bool operator==(const vec2 &v) const {
return (x == v.x) && (y == v.y);
@@ -105,33 +95,33 @@ public:
const vec2 operator+(const T &n) {
return vec2 (x + n, y + n);
}
-};
+
+ // std::swap can't work due to being packed
+
+ inline void swapX(vec2 &v) {
+ float t = x;
+ x = v.x, v.x = t;
+ }
+
+ inline void swapY(vec2 &v) {
+ float t = y;
+ y = v.y, v.y = t;
+ }
+
+} __attribute__ ((packed));
/**
* A structure for three-dimensional points.
*/
-class vec3{
-public:
+struct vec3 {
float x; /**< The x coordinate */
float y; /**< The y coordinate */
float z; /**< The z coordinate */
- vec3() {
- x = y = z = 0.0f;
- }
+ vec3(float _x = 0.0f, float _y = 0.0f, float _z = 1.0f)
+ : x(_x), y(_y), z(_z) {}
- vec3(float _x, float _y, float _z) {
- x = _x;
- y = _y;
- z = _z;
- }
-
- vec3(float _x, float _y) {
- x = _x;
- y = _y;
- z = 1.0f;
- }
-};
+} __attribute__ ((packed));
/**
* This structure contains two sets of coordinates for ray drawing.
diff --git a/include/coolarray.hpp b/include/coolarray.hpp
index be221b8..0df4f18 100644
--- a/include/coolarray.hpp
+++ b/include/coolarray.hpp
@@ -118,7 +118,7 @@ public:
void push_back(const T& x) {
if (_size >= _capacity)
- reserve(_capacity + 5);
+ reserve(_capacity + 10);
buffer[_size++] = x;
}
diff --git a/include/window.hpp b/include/window.hpp
index b642835..d168a54 100644
--- a/include/window.hpp
+++ b/include/window.hpp
@@ -12,7 +12,8 @@ private:
public:
WindowSystem(void);
- ~WindowSystem(void);
+
+ void die(void);
void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
};
diff --git a/include/world.hpp b/include/world.hpp
index 17462ca..a99affa 100644
--- a/include/world.hpp
+++ b/include/world.hpp
@@ -141,11 +141,18 @@ constexpr const char* WorldWeatherString[3] = {
class WorldSystem : public entityx::System<WorldSystem>, public entityx::Receiver<WorldSystem> {
private:
+ World *world;
+
WorldWeather weather;
Mix_Music *bgmObj;
std::string bgmObjFile;
+ std::vector<std::string> bgFiles;
+ std::vector<std::string> bgFilesIndoors;
+
+ TextureIterator bgTex;
+
public:
explicit WorldSystem(void);
~WorldSystem(void);
@@ -157,6 +164,9 @@ public:
void receive(const BGMToggleEvent &bte);
void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
+ void render(void);
+
+ void setWorld(World *w);
inline const std::string getWeatherStr(void) const
{ return WorldWeatherString[static_cast<int>(weather)]; }
@@ -176,8 +186,12 @@ public:
*/
class World {
//friend class ItemLight;
-protected:
+public:
+
+ WorldBGType bgType;
+ std::string styleFolder;
+
/**
* An array of all the world's ground data, populated through
* World::generate().
@@ -196,18 +210,6 @@ protected:
float worldStart;
/**
- * Handles textures for the background elements.
- */
- TextureIterator bgTex;
-
- /**
- * Defines the set of background images being used for the world.
- *
- * @see setBackground()
- */
- WorldBGType bgType;
-
- /**
* The path to the XML file of the world to the left.
*
* @see setToLeft()
@@ -230,20 +232,6 @@ protected:
std::vector<std::string> sTexLoc;
/**
- * The paths of files to be used for the background textures.
- *
- * @see setStyle()
- */
- std::vector<std::string> bgFiles;
-
- /**
- * The paths of files to be used for the indoor background textures.
- *
- * @see setStyle()
- */
- std::vector<std::string> bgFilesIndoors;
-
- /**
* Contains randomly generated coordinates for stars.
*/
std::vector<vec2> star;
@@ -257,13 +245,6 @@ protected:
std::vector<Light> light;
/**
- * A vector of all particles in the world.
- *
- * @see addParticle()
- */
- //CoolArray<Particles> particles;
-
- /**
* A vector of all villages in the world.
*
* @see addVillage()
@@ -284,12 +265,6 @@ protected:
void deleteEntities(void);
/**
- * Draws background textures.
- */
- void drawBackgrounds();
-
-public:
- /**
* The filename of the world's BGM file.
*
* @see setBGM()