powerup.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_POWERUP_HPP
  17. #define HEADER_SUPERTUX_OBJECT_POWERUP_HPP
  18. #include "object/moving_sprite.hpp"
  19. #include "supertux/physic.hpp"
  20. class PowerUp final : public MovingSprite
  21. {
  22. public:
  23. PowerUp(const ReaderMapping& mapping);
  24. PowerUp(const Vector& pos, int type);
  25. GameObjectTypes get_types() const override;
  26. std::string get_default_sprite_name() const override;
  27. virtual void update(float dt_sec) override;
  28. virtual void draw(DrawingContext& context) override;
  29. virtual void collision_solid(const CollisionHit& hit) override;
  30. virtual void on_flip(float height) override;
  31. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  32. static std::string class_name() { return "powerup"; }
  33. virtual std::string get_class_name() const override { return class_name(); }
  34. static std::string display_name() { return _("Powerup"); }
  35. virtual std::string get_display_name() const override { return display_name(); }
  36. std::vector<std::string> get_patches() const override;
  37. virtual ObjectSettings get_settings() override;
  38. virtual void after_editor_set() override;
  39. private:
  40. /** Initialize power up sprites and other defaults */
  41. void initialize();
  42. void setup_lightsprite();
  43. public:
  44. enum Type {
  45. EGG,
  46. FIRE,
  47. ICE,
  48. AIR,
  49. EARTH,
  50. STAR,
  51. ONEUP,
  52. FLIP,
  53. MINTS,
  54. COFFEE,
  55. HERRING
  56. };
  57. private:
  58. Physic physic;
  59. std::string script;
  60. bool no_physics;
  61. SpritePtr lightsprite;
  62. private:
  63. PowerUp(const PowerUp&) = delete;
  64. PowerUp& operator=(const PowerUp&) = delete;
  65. };
  66. #endif
  67. /* EOF */