| 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 | |
| 17 | #ifndef HEADER_SUPERTUX_OBJECT_BLOCK_HPP | 
| 18 | #define HEADER_SUPERTUX_OBJECT_BLOCK_HPP | 
| 19 | |
| 20 | #include "sprite/sprite.hpp" | 
| 21 | #include "sprite/sprite_ptr.hpp" | 
| 22 | #include "supertux/moving_object.hpp" | 
| 23 | |
| 24 | class Player; | 
| 25 | class ReaderMapping; | 
| 26 | |
| 27 | class Block : public MovingObject | 
| 28 | { | 
| 29 | friend class FlipLevelTransformer; | 
| 30 | |
| 31 | public: | 
| 32 | Block(SpritePtr sprite); | 
| 33 | Block(const ReaderMapping& mapping, const std::string& sprite_file); | 
| 34 | |
| 35 | virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override; | 
| 36 | virtual void update(float dt_sec) override; | 
| 37 | virtual void draw(DrawingContext& context) override; | 
| 38 | |
| 39 | virtual std::string get_default_sprite_name() const { return m_default_sprite_name; } | 
| 40 | |
| 41 | virtual ObjectSettings get_settings() override; | 
| 42 | virtual void after_editor_set() override; | 
| 43 | |
| 44 | protected: | 
| 45 | virtual void hit(Player& player) = 0; | 
| 46 | |
| 47 | void start_bounce(GameObject* hitter); | 
| 48 | void start_break(GameObject* hitter); | 
| 49 | void break_me(); | 
| 50 | |
| 51 | protected: | 
| 52 | SpritePtr m_sprite; | 
| 53 | std::string m_sprite_name; | 
| 54 | std::string m_default_sprite_name; | 
| 55 | bool m_bouncing; | 
| 56 | bool m_breaking; | 
| 57 | float m_bounce_dir; | 
| 58 | float m_bounce_offset; | 
| 59 | float m_original_y; | 
| 60 | |
| 61 | private: | 
| 62 | Block(const Block&) = delete; | 
| 63 | Block& operator=(const Block&) = delete; | 
| 64 | }; | 
| 65 | |
| 66 | #endif | 
| 67 | |
| 68 | /* EOF */ | 
| 69 | 
