|
|
@@ -6,19 +6,60 @@
|
|
|
// Copyright © 2019 Sam Jaffe. All rights reserved.
|
|
|
//
|
|
|
|
|
|
+#include <vector>
|
|
|
+
|
|
|
#include "danmaku/bullet_pattern.hpp"
|
|
|
+#include "game/math/angle.hpp"
|
|
|
+#include "game/math/common.hpp"
|
|
|
+#include "game/math/math_fwd.hpp"
|
|
|
#include "resource_factory/prototype_factory.hpp"
|
|
|
+#include "vector/vector.hpp"
|
|
|
+
|
|
|
+using namespace danmaku;
|
|
|
+
|
|
|
+using shot = std::pair<math::vec2, float>;
|
|
|
|
|
|
struct burstshot : public danmaku::bullet_pattern {
|
|
|
static std::shared_ptr<burstshot> create(danmaku::actor*,
|
|
|
Json::Value const &);
|
|
|
|
|
|
- void update(float delta) override {}
|
|
|
+ burstshot(danmaku::actor *, float shot_interval, std::vector<shot> shots);
|
|
|
+ void update(float delta) override;
|
|
|
+
|
|
|
+ danmaku::actor * actor;
|
|
|
+ danmaku::bullet_timer shot_timer;
|
|
|
+ float last_fired{std::numeric_limits<float>::lowest()};
|
|
|
+ std::vector<shot> shots;
|
|
|
};
|
|
|
+
|
|
|
+std::vector<shot> shot_vector(std::size_t count, float facing, float covered,
|
|
|
+ float speed, bool clockwise) {
|
|
|
+ if (covered == 360.f) { ++count; }
|
|
|
+ std::vector<shot> out(count);
|
|
|
+ float start = facing + (.5f * covered);
|
|
|
+ float end = start - covered;
|
|
|
+ if (clockwise != (end < start)) { std::swap(start, end); }
|
|
|
+
|
|
|
+ float const delta = (end - start) / count;
|
|
|
+ float current = start;
|
|
|
+ for (std::size_t i = 0; i < count; ++i, current += delta) {
|
|
|
+ out[i].first = math::rotate({{speed, 0}}, math::degree(current));
|
|
|
+ out[i].second = current + 90;
|
|
|
+ }
|
|
|
+ return out;
|
|
|
+}
|
|
|
+
|
|
|
+burstshot::burstshot(danmaku::actor * actor, float shot_interval,
|
|
|
+ std::vector<shot> shots)
|
|
|
+ : actor(actor), shot_timer{shot_interval}, shots(shots) {}
|
|
|
|
|
|
-std::shared_ptr<burstshot> burstshot::create(danmaku::actor*,
|
|
|
- Json::Value const &) {
|
|
|
- return std::make_shared<burstshot>();
|
|
|
+std::shared_ptr<burstshot> burstshot::create(danmaku::actor* actor,
|
|
|
+ Json::Value const & json) {
|
|
|
+ return std::make_shared<burstshot>(actor, 0.f, shot_vector(0, 0.f, 0.f, 0.f, false));
|
|
|
+}
|
|
|
+
|
|
|
+void burstshot::update(float delta) {
|
|
|
+
|
|
|
}
|
|
|
|
|
|
namespace danmaku {
|