particles.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SuperTux
  2. // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #ifndef HEADER_SUPERTUX_OBJECT_PARTICLES_HPP
  17. #define HEADER_SUPERTUX_OBJECT_PARTICLES_HPP
  18. #include <memory>
  19. #include "math/vector.hpp"
  20. #include "supertux/game_object.hpp"
  21. #include "supertux/timer.hpp"
  22. #include "video/color.hpp"
  23. class Particles final : public GameObject
  24. {
  25. public:
  26. Particles(const Vector& epicenter, int min_angle, int max_angle,
  27. const Vector& initial_velocity, const Vector& acceleration,
  28. int number, Color color, int size, float life_time,
  29. int drawing_layer);
  30. Particles(const Vector& epicenter, int min_angle, int max_angle,
  31. const float min_initial_velocity, const float max_initial_velocity,
  32. const Vector& acceleration, int number, Color color,
  33. int size, float life_time, int drawing_layer);
  34. virtual bool is_saveable() const override {
  35. return false;
  36. }
  37. virtual void update(float dt_sec) override;
  38. virtual void draw(DrawingContext& context) override;
  39. private:
  40. struct Particle {
  41. Vector pos;
  42. Vector vel;
  43. Particle() :
  44. pos(0.0f, 0.0f),
  45. vel(0.0f, 0.0f)
  46. {}
  47. // float angle;
  48. };
  49. private:
  50. Vector accel;
  51. Timer timer;
  52. bool live_forever;
  53. Color color;
  54. float size;
  55. int drawing_layer;
  56. std::vector<std::unique_ptr<Particle> > particles;
  57. };
  58. #endif
  59. /* EOF */