diff options
Diffstat (limited to 'ExampleSource.cpp')
-rw-r--r-- | ExampleSource.cpp | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/ExampleSource.cpp b/ExampleSource.cpp index e79e7ad..fa022e9 100644 --- a/ExampleSource.cpp +++ b/ExampleSource.cpp @@ -1,5 +1,6 @@ #include "ExampleSource.h" +#include <cmath> #include <utility> #include <vector> @@ -8,16 +9,13 @@ #include "Killmail.h" -constexpr int AMOUNT {1000}; constexpr float MAX {4.0f}; constexpr float MIN {-4.0f}; -constexpr float STEP {0.1f}; +constexpr float STEP {0.2f}; -static float random_position(); - - -ExampleSource::ExampleSource() +ExampleSource::ExampleSource() : + m_time {0.0f} { } @@ -26,22 +24,20 @@ std::vector<Killmail> ExampleSource::all() const { std::vector<Killmail> killmails; - killmails.reserve(AMOUNT); - for (int i = 0; i < AMOUNT; ++i) { - Killmail km; - km.position = { - random_position(), - random_position(), - random_position(), - }; - killmails.push_back(std::move(km)); + killmails.reserve(std::pow((MAX - MIN) / STEP, 2)); + m_time += GetFrameTime(); + if (m_time > 2.0f * M_PI) + m_time -= 2.0f * M_PI; + for (float z = MIN; z <= MAX; z += STEP) { + for (float x = MIN; x <= MAX; x += STEP) { + Killmail km; + km.position = { + x, + std::cos(x) + std::cos(z + m_time), + z, + }; + killmails.push_back(std::move(km)); + } } return killmails; } - - -float -random_position() -{ - return GetRandomValue(MIN / STEP, MAX / STEP) * STEP; -} |