supertux
platform.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_PLATFORM_HPP
18 #define HEADER_SUPERTUX_OBJECT_PLATFORM_HPP
19 
20 #include "object/moving_sprite.hpp"
21 #include "object/path_object.hpp"
22 
32 class Platform : public MovingSprite,
33  public PathObject
34 {
35 public:
36  static void register_class(ssq::VM& vm);
37 
38 public:
39  Platform(const ReaderMapping& reader);
40  Platform(const ReaderMapping& reader, const std::string& default_sprite);
41 
42  virtual void finish_construction() override;
43 
44  virtual ObjectSettings get_settings() override;
45 
46  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
47  virtual void update(float dt_sec) override;
48 
49  virtual void move_to(const Vector& pos) override;
50 
51  static std::string class_name() { return "platform"; }
52  virtual std::string get_class_name() const override { return class_name(); }
53  virtual std::string get_exposed_class_name() const override { return "Platform"; }
54  static std::string display_name() { return _("Platform"); }
55  virtual std::string get_display_name() const override { return display_name(); }
56  virtual GameObjectClasses get_class_types() const override { return MovingSprite::get_class_types().add(typeid(PathObject)).add(typeid(Platform)); }
57 
58  virtual void editor_update() override;
59 
60  virtual void on_flip(float height) override;
61 
62  void save_state() override;
63  void check_state() override;
64 
65  const Vector& get_speed() const { return m_speed; }
66  const Vector& get_movement() const { return m_movement; }
67 
70  void jump_to_node(int node_idx);
71 
72 private:
73  Vector m_speed;
74  Vector m_movement;
75 
78  bool m_automatic;
79 
82  bool m_player_contact;
83 
86  bool m_last_player_contact;
87 
88  int m_starting_node;
89 
90 private:
91  Platform(const Platform&) = delete;
92  Platform& operator=(const Platform&) = delete;
93 };
94 
95 #endif
96 
97 /* EOF */
void save_state() override
Save/check the current state of the object.
Definition: platform.cpp:181
This is the base class for platforms that Tux can stand on.
Definition: platform.hpp:32
void jump_to_node(int node_idx)
Moves platform instantly to given node.
Definition: platform.cpp:156
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: platform.cpp:173
Definition: object_settings.hpp:39
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it&#39;s state.
Definition: platform.cpp:101
virtual void finish_construction() override
Called after all objects have been added to the Sector and the Sector is fully constructed.
Definition: platform.cpp:55
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: moving_sprite.hpp:60
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: platform.cpp:92
A base class for all objects that contain, or make use of a path.
Definition: path_object.hpp:36
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 void editor_update() override
Called each frame in the editor, used to keep linked objects together (e.g.
Definition: platform.cpp:144
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: platform.hpp:55
Definition: reader_mapping.hpp:32
Abstract base class for ""MovingObject""s, that are represented by a sprite.
Definition: moving_sprite.hpp:33
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: platform.hpp:56
This class collects data about a collision.
Definition: collision_hit.hpp:44