brick.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // SuperTux
  2. // Copyright (C) 2009 Ingo Ruhnke <grumbel@gmail.com>
  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_BRICK_HPP
  17. #define HEADER_SUPERTUX_OBJECT_BRICK_HPP
  18. #include "object/block.hpp"
  19. class Crusher;
  20. class Brick : public Block
  21. {
  22. public:
  23. Brick(const Vector& pos, int data, const std::string& sprite_name);
  24. Brick(const ReaderMapping& mapping, const std::string& sprite_name = "images/objects/bonus_block/brick.sprite");
  25. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  26. virtual ObjectSettings get_settings() override;
  27. static std::string class_name() { return "brick"; }
  28. virtual std::string get_class_name() const override { return class_name(); }
  29. static std::string display_name() { return _("Brick"); }
  30. virtual std::string get_display_name() const override { return display_name(); }
  31. GameObjectTypes get_types() const override;
  32. std::string get_default_sprite_name() const override;
  33. void try_break(Player* player, bool slider = false);
  34. void break_for_crusher(Crusher* crusher);
  35. protected:
  36. virtual void hit(Player& player) override;
  37. private:
  38. enum Type {
  39. NORMAL,
  40. RETRO
  41. };
  42. private:
  43. bool m_breakable;
  44. int m_coin_counter;
  45. private:
  46. Brick(const Brick&) = delete;
  47. Brick& operator=(const Brick&) = delete;
  48. };
  49. class HeavyBrick : public Brick
  50. {
  51. public:
  52. HeavyBrick(const Vector& pos, int data, const std::string& spriteName);
  53. HeavyBrick(const ReaderMapping& mapping);
  54. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  55. static std::string class_name() { return "heavy-brick"; }
  56. virtual std::string get_class_name() const override { return class_name(); }
  57. static std::string display_name() { return _("Heavy Brick"); }
  58. virtual std::string get_display_name() const override { return display_name(); }
  59. GameObjectTypes get_types() const override { return {}; }
  60. protected:
  61. virtual void hit(Player& player) override;
  62. private:
  63. void ricochet(GameObject* collider);
  64. private:
  65. HeavyBrick(const HeavyBrick&) = delete;
  66. HeavyBrick& operator=(const HeavyBrick&) = delete;
  67. };
  68. #endif
  69. /* EOF */