wind.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // SuperTux - Wind
  2. // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.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_WIND_HPP
  17. #define HEADER_SUPERTUX_OBJECT_WIND_HPP
  18. #include "squirrel/exposed_object.hpp"
  19. #include "scripting/wind.hpp"
  20. #include "supertux/moving_object.hpp"
  21. #include "video/layer.hpp"
  22. class ReaderMapping;
  23. /** Defines an area that will gently push Players in one direction */
  24. class Wind final :
  25. public MovingObject,
  26. public ExposedObject<Wind, scripting::Wind>
  27. {
  28. public:
  29. Wind(const ReaderMapping& reader);
  30. virtual void update(float dt_sec) override;
  31. virtual void draw(DrawingContext& context) override;
  32. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  33. virtual bool has_variable_size() const override { return true; }
  34. static std::string class_name() { return "wind"; }
  35. virtual std::string get_class_name() const override { return class_name(); }
  36. static std::string display_name() { return _("Wind"); }
  37. virtual std::string get_display_name() const override { return display_name(); }
  38. virtual ObjectSettings get_settings() override;
  39. virtual int get_layer() const override { return LAYER_OBJECTS; }
  40. virtual void on_flip(float height) override;
  41. /** @name Scriptable Methods
  42. @{ */
  43. /** start blowing */
  44. void start();
  45. /** stop blowing */
  46. void stop();
  47. /** @} */
  48. private:
  49. bool blowing; /**< true if wind is currently switched on */
  50. Vector speed;
  51. float acceleration;
  52. Vector new_size;
  53. float dt_sec; /**< stores last dt_sec gotten at update() */
  54. bool affects_badguys; /**< whether the wind can affect badguys */
  55. bool affects_objects; /**< whether the wind can affect objects */
  56. bool affects_player; /**< whether the wind can affect the player: useful for cinematic wind */
  57. bool fancy_wind;
  58. private:
  59. Wind(const Wind&) = delete;
  60. Wind& operator=(const Wind&) = delete;
  61. };
  62. #endif
  63. /* EOF */