Reduced code for HeavyCoin used by CoinRain, correcting unusual coin behavior introdu...
authorLMH <lmh.0013@gmail.com>
Sat, 13 Jul 2013 07:03:41 +0000 (21:03 -1000)
committerLMH <lmh.0013@gmail.com>
Sat, 13 Jul 2013 07:03:41 +0000 (21:03 -1000)
src/object/coin.cpp
src/object/coin.hpp
src/object/coin_rain.cpp
src/supertux/object_factory.cpp

index b381473..a1eea59 100644 (file)
@@ -53,7 +53,7 @@ Coin::Coin(const Vector& pos, TileMap* tilemap)
 }
 
 Coin::Coin(const Reader& reader)
-  : MovingSprite(reader, "images/objects/coin/coin.sprite", LAYER_TILES, COLGROUP_MOVING),
+  : MovingSprite(reader, "images/objects/coin/coin.sprite", LAYER_TILES, COLGROUP_TOUCHABLE),
     path(),
     walker(),
     offset(),
@@ -173,14 +173,6 @@ Coin::collision(GameObject& other, const CollisionHit& )
 }
 
 /* The following defines a coin subject to gravity */
-HeavyCoin::HeavyCoin(const Vector& pos)
-  : Coin(pos),
-  physic()
-{
-  physic.enable_gravity(true);
-  sound_manager->preload("sounds/coin.wav");
-}
-
 HeavyCoin::HeavyCoin(const Vector& pos, const Vector& init_velocity)
   : Coin(pos),
   physic()
@@ -190,14 +182,6 @@ HeavyCoin::HeavyCoin(const Vector& pos, const Vector& init_velocity)
   physic.set_velocity(init_velocity);
 }
 
-HeavyCoin::HeavyCoin(const Reader& reader)
-  : Coin(reader),
-  physic()
-{
-  physic.enable_gravity(true);
-  sound_manager->preload("sounds/coin.wav");
-}
-
 void
 HeavyCoin::update(float elapsed_time)
 {
index 91f3bcd..ba517f7 100644 (file)
@@ -47,9 +47,7 @@ private:
 class HeavyCoin : public Coin
 {
 public:
-  HeavyCoin(const Vector& pos);
   HeavyCoin(const Vector& pos, const Vector& init_velocity);
-  HeavyCoin(const Reader& reader);
 
   virtual void update(float elapsed_time);
   virtual void collision_solid(const CollisionHit& hit);
index 42b1317..41f4529 100644 (file)
@@ -50,7 +50,7 @@ CoinRain::update(float elapsed_time)
   } // then the first collectable coin drops from one of ten random positions
   else if (counter==0){
     drop = gameRandom.rand(10);
-    Sector::current()->add_object(new HeavyCoin(Vector (position.x+32*((drop<5)?-drop-1:drop-4),-32)));
+    Sector::current()->add_object(new HeavyCoin(Vector (position.x+32*((drop<5)?-drop-1:drop-4),-32), Vector (0,0)));
     counter++;
     timer.start(DROP_TIME);
   } // finally the remainder of the coins drop in a determined but appears to be a random order
@@ -58,7 +58,7 @@ CoinRain::update(float elapsed_time)
     if(counter<10){
       drop += 7;
       if(drop >= 10) drop -=10;
-      Sector::current()->add_object(new HeavyCoin(Vector (position.x+32*((drop<5)?-drop-1:drop-4),-32)));
+      Sector::current()->add_object(new HeavyCoin(Vector (position.x+32*((drop<5)?-drop-1:drop-4),-32), Vector (0,0)));
       counter++;
       timer.start(DROP_TIME);
     }else{
index fc01e11..318389f 100644 (file)
@@ -232,7 +232,6 @@ ObjectFactory::init_factories()
   add_factory<Explosion>("explosion");
   add_factory<Firefly>("firefly");
   add_factory<Gradient>("gradient");
-  add_factory<HeavyCoin>("heavycoin");
   add_factory<HurtingPlatform>("hurting_platform");
   add_factory<IceCrusher>("icecrusher");
   add_factory<InfoBlock>("infoblock");