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 #include "squirrel/exposed_object.hpp"
23 #include "scripting/platform.hpp"
24 
27 class Platform : public MovingSprite,
28  public ExposedObject<Platform, scripting::Platform>,
29  public PathObject
30 {
31 public:
32  Platform(const ReaderMapping& reader);
33  Platform(const ReaderMapping& reader, const std::string& default_sprite);
34 
35  virtual void finish_construction() override;
36 
37  virtual ObjectSettings get_settings() override;
38 
39  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
40  virtual void update(float dt_sec) override;
41 
42  virtual void move_to(const Vector& pos) override;
43 
44  virtual std::string get_class() const override { return "platform"; }
45  virtual std::string get_display_name() const override { return _("Platform"); }
46 
47  virtual void editor_update() override;
48 
49  const Vector& get_speed() const { return m_speed; }
50 
55  void goto_node(int node_no);
56 
58  void start_moving();
59 
61  void stop_moving();
62 
65 private:
66  Vector m_speed;
67 
70  bool m_automatic;
71 
74  bool m_player_contact;
75 
78  bool m_last_player_contact;
79 
80 private:
81  Platform(const Platform&) = delete;
82  Platform& operator=(const Platform&) = delete;
83 };
84 
85 #endif
86 
87 /* EOF */
This class is the base class for platforms that tux can stand on.
Definition: platform.hpp:27
Simple two dimensional vector.
Definition: vector.hpp:24
This class binds a certain GameObject class to a scripting class.
Definition: exposed_object.hpp:45
void goto_node(int node_no)
Move platform until at given node, then stop.
Definition: platform.cpp:135
void start_moving()
Start moving platform.
Definition: platform.cpp:141
void stop_moving()
Stop platform at next node.
Definition: platform.cpp:147
Definition: object_settings.hpp:35
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:84
virtual void finish_construction() override
Called after all objects have been added to the Sector and the Sector is fully constructed.
Definition: platform.cpp:49
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: platform.cpp:75
A class for all objects that contain / make use of a path.
Definition: path_object.hpp:28
virtual void editor_update() override
Called each frame in the editor, used to keep linked objects together (e.g.
Definition: platform.cpp:126
Definition: reader_mapping.hpp:31
Abstract base class for MovingObjects that are represented by a Sprite.
Definition: moving_sprite.hpp:29
This class collects data about a collision.
Definition: collision_hit.hpp:44