diff options
author | Aki <please@ignore.pl> | 2022-04-18 22:40:41 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-04-18 22:40:41 +0200 |
commit | 5bb6b95fe71d33956491b98c29bf464a440ad221 (patch) | |
tree | d084a1214548ca7c3e9cf167c7462966d0f7fc7f | |
parent | 9dc6e5dcc108cd887891756a54748aab62f19626 (diff) | |
download | bullethell2022-5bb6b95fe71d33956491b98c29bf464a440ad221.zip bullethell2022-5bb6b95fe71d33956491b98c29bf464a440ad221.tar.gz bullethell2022-5bb6b95fe71d33956491b98c29bf464a440ad221.tar.bz2 |
Added toggle for base generator
-rw-r--r-- | ExampleGenerator.cpp | 2 | ||||
-rw-r--r-- | Generator.cpp | 14 | ||||
-rw-r--r-- | Generator.h | 3 |
3 files changed, 19 insertions, 0 deletions
diff --git a/ExampleGenerator.cpp b/ExampleGenerator.cpp index dc9a6b9..5bdade8 100644 --- a/ExampleGenerator.cpp +++ b/ExampleGenerator.cpp @@ -26,6 +26,8 @@ ExampleGenerator::ExampleGenerator(ConstantVelocityBullet::Vector& bullets) : void ExampleGenerator::update(const float dt) { + if (!m_enabled) + return; m_delay += dt; if (m_delay > m_interval) { const auto pos = position(); diff --git a/Generator.cpp b/Generator.cpp index 32ad608..448872d 100644 --- a/Generator.cpp +++ b/Generator.cpp @@ -6,6 +6,20 @@ #include <raylib.h> +Generator::Generator() : + m_enabled {true}, + m_origin {} +{ +} + + +void +Generator::toggle(const bool enabled) +{ + m_enabled = enabled; +} + + void Generator::attach(std::shared_ptr<Vector2> origin) { diff --git a/Generator.h b/Generator.h index 1679055..de3812a 100644 --- a/Generator.h +++ b/Generator.h @@ -8,11 +8,14 @@ class Generator { public: + Generator(); virtual ~Generator() = default; virtual void update(float dt) = 0; + void toggle(bool enabled); void attach(std::shared_ptr<Vector2> origin); void detach(); Vector2 position() const; protected: + bool m_enabled; std::shared_ptr<Vector2> m_origin; }; |