From d7bae41fab5570bdac547a46463974adb4723f96 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 25 Feb 2019 18:47:55 -0500 Subject: mem leak patches; world ground from image --- include/systems/light.hpp | 5 +++++ include/systems/movement.hpp | 22 ++++++++++++++++++++++ include/texture.hpp | 15 +++++++++++++++ include/world.hpp | 7 +++---- 4 files changed, 45 insertions(+), 4 deletions(-) (limited to 'include') 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 { private: static std::vector 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 +#include class MovementSystem : public entityx::System { +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 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 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 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); -- cgit v1.2.3