1 // $Id: Firefly.cpp 2979 2006-01-10 00:00:04Z matzebraun $
4 // Copyright (C) 2005 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
22 #include "firefly.hpp"
23 #include "resources.hpp"
24 #include "sprite/sprite_manager.hpp"
25 #include "video/drawing_context.hpp"
27 #include "object_factory.hpp"
28 #include "game_session.hpp"
31 Firefly::Firefly(const lisp::Lisp& lisp)
34 lisp.get("x", bbox.p1.x);
35 lisp.get("y", bbox.p1.y);
36 bbox.set_size(32, 32);
37 sprite = sprite_manager->create("images/objects/firefly/firefly.sprite");
38 set_group(COLGROUP_TOUCHABLE);
47 Firefly::write(lisp::Writer& writer)
49 writer.start_list("firefly");
50 writer.write_float("x", bbox.p1.x);
51 writer.write_float("y", bbox.p1.y);
52 writer.end_list("Firefly");
56 Firefly::update(float )
61 Firefly::draw(DrawingContext& context)
63 sprite->draw(context, get_pos(), LAYER_TILES);
67 Firefly::collision(GameObject& other, const CollisionHit& )
72 Player* player = dynamic_cast<Player*> (&other);
76 sprite->set_action("ringing");
77 GameSession::current()->set_reset_point(Sector::current()->get_name(),
84 IMPLEMENT_FACTORY(Firefly, "firefly");