aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2019-02-25 18:47:55 -0500
committerClyne Sullivan <tullivan99@gmail.com>2019-02-25 18:47:55 -0500
commitd7bae41fab5570bdac547a46463974adb4723f96 (patch)
tree37b0567300f2e3d0a74ceae5861272f4ff970558 /include
parent58774909a78f06b8de3cb60e2f010e8ceccbf3a6 (diff)
mem leak patches; world ground from image
Diffstat (limited to 'include')
-rw-r--r--include/systems/light.hpp5
-rw-r--r--include/systems/movement.hpp22
-rw-r--r--include/texture.hpp15
-rw-r--r--include/world.hpp7
4 files changed, 45 insertions, 4 deletions
diff --git a/include/systems/light.hpp b/include/systems/light.hpp
index ba91113..02c7eed 100644
--- a/include/systems/light.hpp
+++ b/include/systems/light.hpp
@@ -21,6 +21,11 @@ class LightSystem : public entityx::System<LightSystem> {
private:
static std::vector<Light> lights;
+ static GLfloat *colorData;
+ static GLfloat *coordData;
+
+ static void resizeLights(void);
+
public:
void update(entityx::EntityManager& en, entityx::EventManager& ev, entityx::TimeDelta dt) override;
diff --git a/include/systems/movement.hpp b/include/systems/movement.hpp
index fd37665..745fa9b 100644
--- a/include/systems/movement.hpp
+++ b/include/systems/movement.hpp
@@ -2,10 +2,32 @@
#define SYSTEM_MOVEMENT_HPP_
#include <entityx/entityx.h>
+#include <attack.hpp>
class MovementSystem : public entityx::System<MovementSystem> {
+private:
+ constexpr static const char *hitPlayerScript = "\
+ effect = function()\n \
+ flash(255, 0, 0)\n \
+ damage(1)\n \
+ end\n \
+ hit = function()\n \
+ xrange = 5\n \
+ end";
+ static LuaScript hitPlayer;
+ static Attack playerAttack;
+
public:
+ MovementSystem(void) {
+ hitPlayer = LuaScript(hitPlayerScript);
+ AttackSystem::initLua(hitPlayer);
+ playerAttack = { vec2(), vec2(5, 5), vec2(), vec2(),
+ hitPlayer, TextureIterator() };
+ }
+
void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
+
+ static int doAttack(lua_State *);
};
#endif // SYSTEM_MOVEMENT_HPP_
diff --git a/include/texture.hpp b/include/texture.hpp
index d4bcfa9..db16357 100644
--- a/include/texture.hpp
+++ b/include/texture.hpp
@@ -174,4 +174,19 @@ public:
*/
void unloadTextures(void);
+class ObjectTexture : public Texture {
+private:
+ std::vector<bool> solidMap;
+ bool valid;
+
+public:
+ ObjectTexture(const std::string filename = "");
+
+ int getHeight(int index);
+ bool isInsideObject(vec2 coord) const;
+ inline bool isValid(void) {
+ return valid;
+ }
+};
+
#endif //TEXTURE_HPP_
diff --git a/include/world.hpp b/include/world.hpp
index 0bfe078..d53a40b 100644
--- a/include/world.hpp
+++ b/include/world.hpp
@@ -69,7 +69,7 @@ constexpr const unsigned int INDOOR_FLOOR_HEIGHT = (INDOOR_FLOOR_HEIGHTT + INDOO
struct WorldData2 {
// Data variables
- std::vector<WorldData> data; /**< The world's ground data. */
+ ObjectTexture ground;
float startX; /**< The furthest left coordinate of the world. */
// Indoor variables
@@ -125,8 +125,6 @@ private:
static std::vector<vec2> stars;
- static int getLineIndex(float x);
-
public:
static std::thread thAmbient;
@@ -159,7 +157,8 @@ public:
static void goWorldRight(Position& p, Solid &d);
static void goWorldPortal(Position& p);
- static void generate(LuaScript& script);
+ static void generate(const char *file);
+ static float getGroundHeight(float x);
static bool save(void);
static void load(const std::string& file);