Merged changes from branches/supertux-milestone2-grumbel/ to trunk/supertux/
[supertux.git] / src / trigger / door.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_TRIGGER_DOOR_HPP
18 #define HEADER_SUPERTUX_TRIGGER_DOOR_HPP
19
20 #include "sprite/sprite.hpp"
21 #include "trigger/trigger_base.hpp"
22
23 class Player;
24
25 class Door : public TriggerBase
26 {
27 public:
28   Door(const Reader& reader);
29   Door(int x, int y, std::string sector, std::string spawnpoint);
30   virtual ~Door();
31
32   virtual void update(float elapsed_time);
33   virtual void draw(DrawingContext& context);
34   virtual void event(Player& player, EventType type);
35   virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
36
37 private:
38   enum DoorState {
39     CLOSED,
40     OPENING,
41     OPEN,
42     CLOSING
43   };
44
45 private:
46   DoorState state; /**< current state of the door */
47   std::string target_sector; /**< target sector to teleport to */
48   std::string target_spawnpoint; /**< target spawnpoint to teleport to */
49   std::auto_ptr<Sprite> sprite; /**< "door" sprite to render */
50   Timer stay_open_timer; /**< time until door will close again */
51 };
52
53 #endif
54
55 /* EOF */