Platform that hurts Tux and Badguys when touched
[supertux.git] / src / object / firefly.cpp
index a9278c3..dc9adff 100644 (file)
@@ -1,7 +1,7 @@
-//  $Id: Firefly.cpp 2979 2006-01-10 00:00:04Z matzebraun $
-// 
+//  $Id$
+//
 //  SuperTux
-//  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
+//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 //  GNU General Public License for more details.
-// 
+//
 //  You should have received a copy of the GNU General Public License
 //  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-//  02111-1307, USA.
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
 #include <config.h>
 
 #include "firefly.hpp"
 #include "sector.hpp"
 
 Firefly::Firefly(const lisp::Lisp& lisp)
-  : ringing(false)
+       : MovingSprite(lisp, "images/objects/firefly/firefly.sprite", LAYER_TILES, COLGROUP_TOUCHABLE), activated(false)
 {
-  lisp.get("x", bbox.p1.x);
-  lisp.get("y", bbox.p1.y);
-  bbox.set_size(32, 32);
-  sprite = sprite_manager->create("images/objects/firefly/firefly.sprite");
-  set_group(COLGROUP_TOUCHABLE);
-}
-
-Firefly::~Firefly()
-{
-  delete sprite;
 }
 
 void
@@ -49,29 +39,18 @@ Firefly::write(lisp::Writer& writer)
   writer.start_list("firefly");
   writer.write_float("x", bbox.p1.x);
   writer.write_float("y", bbox.p1.y);
-  writer.end_list("Firefly");
-}
-
-void
-Firefly::update(float )
-{
-}
-
-void
-Firefly::draw(DrawingContext& context)
-{
-  sprite->draw(context, get_pos(), LAYER_TILES);
+  writer.end_list("firefly");
 }
 
 HitResponse
 Firefly::collision(GameObject& other, const CollisionHit& )
 {
-  if(ringing)
+  if(activated)
     return ABORT_MOVE;
   
   Player* player = dynamic_cast<Player*> (&other);
   if(player) {
-    ringing = true;
+    activated = true;
     // TODO play sound
     sprite->set_action("ringing");
     GameSession::current()->set_reset_point(Sector::current()->get_name(),