supertux
invisible_block.hpp
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_INVISIBLE_BLOCK_HPP
18 #define HEADER_SUPERTUX_OBJECT_INVISIBLE_BLOCK_HPP
19 
20 #include "object/block.hpp"
21 
22 class InvisibleBlock final : public Block
23 {
24 public:
25  InvisibleBlock(const Vector& pos);
26  InvisibleBlock(const ReaderMapping& mapping);
27 
28  static std::string class_name() { return "invisible_block"; }
29  virtual std::string get_class_name() const override { return class_name(); }
30  static std::string display_name() { return _("Invisible Block"); }
31  virtual std::string get_display_name() const override { return display_name(); }
32  virtual GameObjectClasses get_class_types() const override { return Block::get_class_types().add(typeid(InvisibleBlock)); }
33 
34  virtual void draw(DrawingContext& context) override;
35  virtual bool collides(GameObject& other, const CollisionHit& hit) const override;
36  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
37 
38  GameObjectTypes get_types() const override;
39  std::string get_default_sprite_name() const override;
40 
41 private:
42  virtual void hit(Player& player) override;
43 
44 private:
45  enum Type {
46  NORMAL,
47  RETRO
48  };
49 
50 private:
51  bool visible;
52 
53 private:
54  InvisibleBlock(const InvisibleBlock&) = delete;
55  InvisibleBlock& operator=(const InvisibleBlock&) = delete;
56 };
57 
58 #endif
59 
60 /* EOF */
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: invisible_block.hpp:31
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: invisible_block.hpp:32
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: invisible_block.cpp:79
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: invisible_block.cpp:55
GameObjectTypes get_types() const override
Get all types of the object, if available.
Definition: invisible_block.cpp:34
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
Definition: invisible_block.hpp:22
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: block.hpp:33
Definition: reader_mapping.hpp:32
This module contains methods controlling the player.
Definition: player.hpp:47
Definition: block.hpp:25
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
virtual bool collides(GameObject &other, const CollisionHit &hit) const override
when 2 objects collided, we will first call the collision functions of both objects that can decide o...
Definition: invisible_block.cpp:62
This class collects data about a collision.
Definition: collision_hit.hpp:44