diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-01-09 09:20:14 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-01-09 09:20:14 -0500 |
commit | 9d7b4c9a40261b5b6b961f6ca6174fd23c40f6b8 (patch) | |
tree | 10df7ef782baa34a0770d61cc81752917aca3cee /include | |
parent | eb6f6d035f0b4324d881f5057639474095a02858 (diff) |
independent particle colors
Diffstat (limited to 'include')
-rw-r--r-- | include/particle.hpp | 16 | ||||
-rw-r--r-- | include/weather.hpp | 4 |
2 files changed, 11 insertions, 9 deletions
diff --git a/include/particle.hpp b/include/particle.hpp index 63f23e3..3fcd409 100644 --- a/include/particle.hpp +++ b/include/particle.hpp @@ -2,6 +2,7 @@ #define PARTICLE_HPP_ #include <common.hpp> +#include <texture.hpp> #include <list> @@ -18,12 +19,11 @@ struct Particle { vec2 velocity; ParticleType type; int timeLeft; + vec2 color; // assets/colorIndex.png - //const Texture& color; // TODO - - Particle(vec2 p, ParticleType t = ParticleType::Drop, int tl = 3000) - : location(p), type(t), timeLeft(tl) {} -} __attribute__ ((packed)); + Particle(vec2 p, ParticleType t, int tl, vec2 c) + : location(p), type(t), timeLeft(tl), color(c) {} +};// __attribute__ ((packed)); class ParticleSystem : public entityx::System<ParticleSystem> { private: @@ -33,8 +33,10 @@ private: public: ParticleSystem(int count = 2048, bool m = false); - void add(const vec2& pos, const ParticleType& type, const int& timeleft = 3000); - void addMultiple(const int& count, const ParticleType& type, std::function<vec2(void)> f, const int& timeleft = 3000); + void add(const vec2& pos, const ParticleType& type, const int& timeleft = 3000, + const unsigned char& color = 0); + void addMultiple(const int& count, const ParticleType& type, std::function<vec2(void)> f, + const int& timeleft = 3000, const unsigned char& color = 0); void render(void); void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override; diff --git a/include/weather.hpp b/include/weather.hpp index c348c15..f2f5fed 100644 --- a/include/weather.hpp +++ b/include/weather.hpp @@ -48,7 +48,7 @@ public: newPartDelay = 0; partSystem.add(vec2(offset.x - game::SCREEN_WIDTH / 2 + randGet() % game::SCREEN_WIDTH, offset.y + game::SCREEN_HEIGHT / 2 + 100), - ParticleType::Drop); + ParticleType::Drop, 3000, 3); } break; // TODO case Weather::Snowy: @@ -56,7 +56,7 @@ public: newPartDelay = 0; partSystem.add(vec2(offset.x - game::SCREEN_WIDTH / 2 + randGet() % game::SCREEN_WIDTH, offset.y + game::SCREEN_HEIGHT / 2 + 100), - ParticleType::Confetti, 6000); + ParticleType::Confetti, 6000, 0); } break; // TODO default: |