1 // Copyright (C) 2020 Daniel Ward <weluvgoatz@gmail.com> 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 #ifndef HEADER_SUPERTUX_OBJECT_FALLBLOCK_HPP 17 #define HEADER_SUPERTUX_OBJECT_FALLBLOCK_HPP 18 19 #include "object/moving_sprite.hpp" 20 #include "supertux/physic.hpp" 21 #include "supertux/timer.hpp" 22 23 class Player; 24 25 class FallBlock : public MovingSprite 26 27 { 28 public: 29 FallBlock(const ReaderMapping& reader); 30 31 virtual void update(float dt_sec) override; 32 33 virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override; 34 virtual void collision_solid(const CollisionHit& hit) override; 35 36 virtual void draw(DrawingContext& context) override; 37 get_class() const38 virtual std::string get_class() const override { return "fallblock"; } get_display_name() const39 virtual std::string get_display_name() const override { return _("Falling Platform"); } 40 41 protected: 42 enum State 43 { 44 IDLE, 45 SHAKE, 46 FALL, 47 LAND 48 }; 49 50 private: 51 State state; 52 53 Physic physic; 54 Timer timer; 55 56 bool found_victim_down() const; 57 58 private: 59 FallBlock(const FallBlock&) = delete; 60 FallBlock& operator=(const FallBlock&) = delete; 61 }; 62 63 #endif 64 65 /* EOF */ 66