3 // SuperTux - A Jump'n Run
4 // Copyright (C) 2004 Matthias Braun <matze@braunis.de
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #include "utils/lispreader.h"
23 #include "utils/lispwriter.h"
25 #include "resources.h"
26 #include "special/sprite.h"
27 #include "special/sprite_manager.h"
28 #include "video/drawing_context.h"
29 #include "app/globals.h"
31 using namespace SuperTux;
33 Door::Door(LispReader& reader)
35 reader.read_float("x", bbox.p1.x);
36 reader.read_float("y", bbox.p1.y);
37 bbox.set_size(32, 64);
39 reader.read_string("sector", target_sector);
40 reader.read_string("spawnpoint", target_spawnpoint);
42 sprite = sprite_manager->create("door");
45 Door::Door(int x, int y)
47 bbox.set_pos(Vector(x, y));
48 bbox.set_size(32, 64);
50 sprite = sprite_manager->create("door");
59 Door::write(LispWriter& writer)
61 writer.start_list("door");
63 writer.write_float("x", bbox.p1.x);
64 writer.write_float("y", bbox.p1.y);
65 writer.write_float("width", bbox.get_width());
66 writer.write_float("height", bbox.get_height());
68 writer.write_string("sector", target_sector);
69 writer.write_string("spawnpoint", target_spawnpoint);
71 writer.end_list("door");
77 //Check if door animation is complete
78 if (!sprite->check_animation()) {
79 GameSession::current()->respawn(target_sector, target_spawnpoint);
84 Door::draw(DrawingContext& context)
86 sprite->draw(context, bbox.p1, LAYER_TILES);
90 Door::event(Player& , EventType type)
92 if(type == EVENT_ACTIVATE) {
93 sprite->set_action("open");
94 sprite->start_animation(1);