Browse Source

Fixing updates for enemy and burstshot pattern.

Sam Jaffe 6 years ago
parent
commit
81a4c32cfc
3 changed files with 7 additions and 2 deletions
  1. 1 1
      include/danmaku/enemy.hpp
  2. 5 0
      src/entity/enemy.cxx
  3. 1 1
      src/pattern/burstshot_pattern.cxx

+ 1 - 1
include/danmaku/enemy.hpp

@@ -21,7 +21,7 @@ namespace danmaku {
     enemy(Json::Value const & json, graphics::object const & obj,
           attack_factory get_attack);
 
-    void update(float delta) override { entity::update(delta); }
+    void update(float delta) override;
     void level(class level * l) override { level_ = l; }
     class level * level() const override {
       return level_;

+ 5 - 0
src/entity/enemy.cxx

@@ -22,6 +22,11 @@ enemy::enemy(Json::Value const & json, graphics::object const & obj,
   attack_ = to_vector(json["attack"], get_attack, this);
 }
 
+void enemy::update(float delta) {
+  entity::update(delta);
+  attack_[0]->update(delta);
+}
+
 std::unique_ptr<enemy> make_enemy(Json::Value const & json,
                                   graphics::object const & obj,
                                   attack_factory get_attack) {

+ 1 - 1
src/pattern/burstshot_pattern.cxx

@@ -83,7 +83,7 @@ burstshot::create(danmaku::actor * actor, Json::Value const & json,
 void burstshot::update(float delta) {
   if ((shot_timer.remaining -= delta) <= 0.f) {
     shot_timer.remaining = shot_timer.interval;
-    std::size_t shots_fired = std::size_t(delta / shots.size());
+    float shots_fired = delta / shots.size();
     while (shots_fired-- > 0) {
       bullet new_bullet{bullet_proto};
       new_bullet.set_velocity(shots[idx].first);