summaryrefslogtreecommitdiffhomepage
path: root/ExampleGenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ExampleGenerator.cpp')
-rw-r--r--ExampleGenerator.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/ExampleGenerator.cpp b/ExampleGenerator.cpp
index 5bdade8..f405f58 100644
--- a/ExampleGenerator.cpp
+++ b/ExampleGenerator.cpp
@@ -1,6 +1,7 @@
#include "ExampleGenerator.h"
#include <cmath>
+#include <memory>
#include <utility>
#include <raylib.h>
@@ -8,7 +9,8 @@
#include "ConstantVelocity.h"
-ExampleGenerator::ExampleGenerator(ConstantVelocityBullet::Vector& bullets) :
+ExampleGenerator::ExampleGenerator(std::shared_ptr<Vector2> position, ConstantVelocityBullet::Vector& bullets) :
+ m_position {position},
m_bullets {bullets},
m_delay {0},
m_interval {0.08f},
@@ -30,7 +32,6 @@ ExampleGenerator::update(const float dt)
return;
m_delay += dt;
if (m_delay > m_interval) {
- const auto pos = position();
m_delay -= m_interval;
m_color.g = 0;
for (float i = 0; i <= m_segments; ++i) {
@@ -42,8 +43,8 @@ ExampleGenerator::update(const float dt)
bullet.radius = 3;
bullet.velocity.x = cos * m_speed;
bullet.velocity.y = sin * m_speed;
- bullet.position.x = pos.x + cos * m_shift;
- bullet.position.y = pos.y + sin * m_shift;
+ bullet.position.x = m_position->x + cos * m_shift;
+ bullet.position.y = m_position->y + sin * m_shift;
m_bullets.push_back(std::move(bullet));
m_color.g += 20;
}