From c0b1f81b0b036a91b06c964d4a47e956224b7cca Mon Sep 17 00:00:00 2001 From: LMH Date: Fri, 12 Jul 2013 21:03:41 -1000 Subject: [PATCH] Reduced code for HeavyCoin used by CoinRain, correcting unusual coin behavior introduced in commit 4ed4ca8 --- src/object/coin.cpp | 18 +----------------- src/object/coin.hpp | 2 -- src/object/coin_rain.cpp | 4 ++-- src/supertux/object_factory.cpp | 1 - 4 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/object/coin.cpp b/src/object/coin.cpp index b381473f369..a1eea594fe9 100644 --- a/src/object/coin.cpp +++ b/src/object/coin.cpp @@ -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) { diff --git a/src/object/coin.hpp b/src/object/coin.hpp index 91f3bcd5098..ba517f7e73f 100644 --- a/src/object/coin.hpp +++ b/src/object/coin.hpp @@ -47,9 +47,7 @@ class Coin : public MovingSprite 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); diff --git a/src/object/coin_rain.cpp b/src/object/coin_rain.cpp index 42b1317e5d2..41f4529dfd7 100644 --- a/src/object/coin_rain.cpp +++ b/src/object/coin_rain.cpp @@ -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{ diff --git a/src/supertux/object_factory.cpp b/src/supertux/object_factory.cpp index fc01e111dd0..318389fa150 100644 --- a/src/supertux/object_factory.cpp +++ b/src/supertux/object_factory.cpp @@ -232,7 +232,6 @@ ObjectFactory::init_factories() add_factory("explosion"); add_factory("firefly"); add_factory("gradient"); - add_factory("heavycoin"); add_factory("hurting_platform"); add_factory("icecrusher"); add_factory("infoblock");