scripted_object.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_SCRIPTED_OBJECT_HPP
  17. #define HEADER_SUPERTUX_OBJECT_SCRIPTED_OBJECT_HPP
  18. #include "object/moving_sprite.hpp"
  19. #include "scripting/scripted_object.hpp"
  20. #include "squirrel/exposed_object.hpp"
  21. #include "supertux/physic.hpp"
  22. class ScriptedObject final :
  23. public MovingSprite,
  24. public ExposedObject<ScriptedObject, scripting::ScriptedObject>
  25. {
  26. public:
  27. ScriptedObject(const ReaderMapping& mapping);
  28. virtual void update(float dt_sec) override;
  29. virtual void draw(DrawingContext& context) override;
  30. virtual void collision_solid(const CollisionHit& hit) override;
  31. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  32. static std::string class_name() { return "scriptedobject"; }
  33. virtual std::string get_class_name() const override { return class_name(); }
  34. static std::string display_name() { return _("Scripted Object"); }
  35. virtual std::string get_display_name() const override { return display_name(); }
  36. virtual ObjectSettings get_settings() override;
  37. virtual void on_flip(float height) override;
  38. void move(float x, float y);
  39. float get_pos_x() const;
  40. float get_pos_y() const;
  41. void set_velocity(float x, float y);
  42. float get_velocity_x() const;
  43. float get_velocity_y() const;
  44. void set_visible(bool visible);
  45. bool is_visible() const;
  46. void set_solid(bool solid);
  47. bool is_solid() const;
  48. void enable_gravity(bool f);
  49. bool gravity_enabled() const;
  50. private:
  51. Physic physic;
  52. bool solid;
  53. bool physic_enabled;
  54. bool visible;
  55. std::string hit_script;
  56. bool new_vel_set;
  57. Vector new_vel;
  58. Vector new_size;
  59. private:
  60. ScriptedObject(const ScriptedObject&) = delete;
  61. ScriptedObject& operator=(const ScriptedObject&) = delete;
  62. };
  63. #endif
  64. /* EOF */