enemy.cxx 1013 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // enemy.cxx
  3. // danmaku
  4. //
  5. // Created by Sam Jaffe on 5/26/19.
  6. // Copyright © 2019 Sam Jaffe. All rights reserved.
  7. //
  8. #include "danmaku/enemy.hpp"
  9. #include <json/json.h>
  10. #include "danmaku/bullet_pattern.hpp"
  11. #include "danmaku/serial.hpp"
  12. #include "resource_factory/prototype_factory.hpp"
  13. using namespace danmaku;
  14. enemy::enemy(Json::Value const & json, graphics::object const & obj,
  15. attack_factory get_attack)
  16. : actor(json, obj), points_(to_points_map(json["points"])) {
  17. attack_ = to_vector(json["attack"], get_attack, this);
  18. }
  19. void enemy::update(float delta) {
  20. entity::update(delta);
  21. attack_[0]->update(delta);
  22. }
  23. std::unique_ptr<enemy> make_enemy(Json::Value const & json,
  24. graphics::object const & obj,
  25. attack_factory get_attack) {
  26. return std::make_unique<enemy>(json, obj, get_attack);
  27. }
  28. BIND_ACTOR("enemy", &make_enemy);
  29. // to_vector(Json::Value, attack_factory, actor*)
  30. #include "danmaku/serial.tpp"