2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
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.
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.
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/>.
17 #ifndef HEADER_SUPERTUX_TRIGGER_TRIGGER_BASE_HPP
18 #define HEADER_SUPERTUX_TRIGGER_TRIGGER_BASE_HPP
23 #include "supertux/moving_object.hpp"
24 #include "supertux/object_remove_listener.hpp"
29 /** This class is the base class for all objects you can interact with in some
30 * way. There are several interaction types defined like touch and activate
32 class TriggerBase : public MovingObject,
33 public ObjectRemoveListener
37 EVENT_TOUCH, /**< Object came into contact */
38 EVENT_LOSETOUCH, /**< Lost contact with object */
39 EVENT_ACTIVATE /**< Action button pressed */
45 void update(float elapsed_time);
46 void draw(DrawingContext& context);
47 HitResponse collision(GameObject& other, const CollisionHit& hit);
50 * Receive trigger events
52 virtual void event(Player& player, EventType type) = 0;
55 * Called by GameObject destructor of an object in losetouch_listeners
57 virtual void object_removed(GameObject* object);
60 std::auto_ptr<Sprite> sprite;
64 std::list<Player*> losetouch_listeners; /**< Players that will be informed when we lose touch with them */
67 TriggerBase(const TriggerBase&);
68 TriggerBase& operator=(const TriggerBase&);
71 #endif /*SUPERTUX_INTERACTIVE_OBJECT_H*/