weak_block.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // SuperTux - Weak Block
  2. // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
  3. // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef HEADER_SUPERTUX_OBJECT_WEAK_BLOCK_HPP
  18. #define HEADER_SUPERTUX_OBJECT_WEAK_BLOCK_HPP
  19. #include "object/moving_sprite.hpp"
  20. class Bullet;
  21. /** A block that can be destroyed by Bullet hits */
  22. class WeakBlock final : public MovingSprite
  23. {
  24. public:
  25. WeakBlock(const ReaderMapping& mapping);
  26. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  27. virtual void update(float dt_sec) override;
  28. virtual void draw(DrawingContext& context) override;
  29. static std::string class_name() { return "weak_block"; }
  30. virtual std::string get_class_name() const override { return class_name(); }
  31. static std::string display_name() { return _("Weak Tile"); }
  32. virtual std::string get_display_name() const override { return display_name(); }
  33. std::vector<std::string> get_patches() const override;
  34. void update_version() override;
  35. void save(Writer& writer) override;
  36. GameObjectTypes get_types() const override;
  37. std::string get_default_sprite_name() const override;
  38. virtual void on_flip(float height) override;
  39. void startBurning();
  40. private:
  41. virtual HitResponse collision_bullet(Bullet& bullet, const CollisionHit& hit);
  42. private:
  43. /** called by self when hit by a bullet */
  44. /** pass hit to nearby WeakBlock objects */
  45. void spreadHit();
  46. private:
  47. enum Type {
  48. ICE,
  49. HAY
  50. };
  51. enum State {
  52. STATE_NORMAL, /**< default state */
  53. STATE_BURNING, /**< on fire, still solid */
  54. STATE_DISINTEGRATING /**< crumbling to dust, no longer solid */
  55. };
  56. private:
  57. State state;
  58. SpritePtr lightsprite;
  59. private:
  60. WeakBlock(const WeakBlock&) = delete;
  61. WeakBlock& operator=(const WeakBlock&) = delete;
  62. };
  63. #endif
  64. /* EOF */