rock.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_ROCK_HPP
  17. #define HEADER_SUPERTUX_OBJECT_ROCK_HPP
  18. #include "object/moving_sprite.hpp"
  19. #include "object/portable.hpp"
  20. #include "squirrel/exposed_object.hpp"
  21. #include "scripting/rock.hpp"
  22. #include "supertux/physic.hpp"
  23. class Rock : public MovingSprite,
  24. public Portable,
  25. public ExposedObject<Rock, scripting::Rock>
  26. {
  27. public:
  28. Rock(const ReaderMapping& reader, const std::string& spritename = "images/objects/rock/rock.sprite");
  29. Rock(const Vector& pos, const std::string& spritename = "images/objects/rock/rock.sprite");
  30. virtual void collision_solid(const CollisionHit& hit) override;
  31. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  32. virtual void update(float dt_sec) override;
  33. virtual void grab(MovingObject& object, const Vector& pos, Direction dir) override;
  34. virtual void ungrab(MovingObject& object, Direction dir) override;
  35. static std::string class_name() { return "rock"; }
  36. virtual std::string get_class_name() const override { return class_name(); }
  37. static std::string display_name() { return _("Rock"); }
  38. virtual std::string get_display_name() const override { return display_name(); }
  39. virtual ObjectSettings get_settings() override;
  40. virtual GameObjectTypes get_types() const override;
  41. std::string get_default_sprite_name() const override;
  42. /** Adds velocity from wind */
  43. virtual void add_wind_velocity(const Vector& velocity, const Vector& end_speed);
  44. private:
  45. enum Type {
  46. SMALL,
  47. LARGE
  48. };
  49. protected:
  50. Physic physic;
  51. bool on_ground;
  52. Vector last_movement;
  53. std::string on_grab_script;
  54. std::string on_ungrab_script;
  55. private:
  56. Rock(const Rock&) = delete;
  57. Rock& operator=(const Rock&) = delete;
  58. };
  59. #endif
  60. /* EOF */