diff options
-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; }; |