Platform that hurts Tux and Badguys when touched
[supertux.git] / src / object / coin.cpp
index 36b035a..566d294 100644 (file)
 #include "timer.hpp"
 
 Coin::Coin(const Vector& pos)
+       : MovingSprite(pos, "images/objects/coin/coin.sprite", LAYER_TILES, COLGROUP_TOUCHABLE)
 {
-  bbox.set_pos(pos);
-  bbox.set_size(32, 32);
-  sprite = sprite_manager->create("images/objects/coin/coin.sprite");
-  set_group(COLGROUP_TOUCHABLE);
 }
 
 Coin::Coin(const lisp::Lisp& reader)
+       : MovingSprite(reader, "images/objects/coin/coin.sprite", LAYER_TILES, COLGROUP_TOUCHABLE)
 {
-  reader.get("x", bbox.p1.x);
-  reader.get("y", bbox.p1.y);
-  bbox.set_size(32, 32);
-  sprite = sprite_manager->create("images/objects/coin/coin.sprite");
-  set_group(COLGROUP_TOUCHABLE);
-}
-
-Coin::~Coin()
-{
-  delete sprite;
-}
-
-void
-Coin::update(float )
-{
-}
-
-void
-Coin::draw(DrawingContext& context)
-{
-  sprite->draw(context, get_pos(), LAYER_TILES);
 }
 
 void
 Coin::collect()
 {
-  static Timer sound_timer; /**< time since last Coin was collected */
+  // TODO: commented out musical code. Maybe fork this for a special "MusicalCoin" object?
+  /*
+  static Timer sound_timer; 
   static int pitch_one = 128;
   static float last_pitch = 1;
   float pitch = 1;
@@ -137,8 +116,8 @@ Coin::collect()
   soundSource->set_position(get_pos());
   soundSource->set_pitch(pitch);
   sound_manager->play_and_delete(soundSource);
-
-  Sector::current()->player->get_status()->add_coins(1, false);
+*/
+  Sector::current()->player->get_status()->add_coins(1);
   Sector::current()->add_object(new BouncyCoin(get_pos()));
   Sector::current()->get_level()->stats.coins++;
   remove_me();