Skip to content

Commit

Permalink
Reduced code for HeavyCoin used by CoinRain, correcting unusual coin …
Browse files Browse the repository at this point in the history
…behavior introduced in commit 4ed4ca8
  • Loading branch information
LMH0013 committed Jul 13, 2013
1 parent 11e1507 commit c0b1f81
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 22 deletions.
18 changes: 1 addition & 17 deletions src/object/coin.cpp
Expand Up @@ -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(),
Expand Down Expand Up @@ -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()
Expand All @@ -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)
{
Expand Down
2 changes: 0 additions & 2 deletions src/object/coin.hpp
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/object/coin_rain.cpp
Expand Up @@ -50,15 +50,15 @@ 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
else if(timer.check()){
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{
Expand Down
1 change: 0 additions & 1 deletion src/supertux/object_factory.cpp
Expand Up @@ -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");
Expand Down

0 comments on commit c0b1f81

Please sign in to comment.