+/* The following defines a coin subject to gravity */
+HeavyCoin::HeavyCoin(const Vector& pos, const Vector& init_velocity)
+ : Coin(pos),
+ physic()
+{
+ physic.enable_gravity(true);
+ SoundManager::current()->preload("sounds/coin2.ogg");
+ set_group(COLGROUP_MOVING);
+ physic.set_velocity(init_velocity);
+}
+
+HeavyCoin::HeavyCoin(const Reader& reader)
+ : Coin(reader),
+ physic()
+{
+ physic.enable_gravity(true);
+ SoundManager::current()->preload("sounds/coin2.ogg");
+ set_group(COLGROUP_MOVING);
+}
+
+void
+HeavyCoin::update(float elapsed_time)
+{
+ // enable physics
+ movement = physic.get_movement(elapsed_time);
+}
+
+void
+HeavyCoin::collision_solid(const CollisionHit& hit)
+{
+ int clink_threshold = 100; // sets the minimum speed needed to result in collision noise
+ //TODO: colliding HeavyCoins should have their own unique sound
+
+ if(hit.bottom) {
+ if(physic.get_velocity_y() > clink_threshold)
+ SoundManager::current()->play("sounds/coin2.ogg");
+ if(physic.get_velocity_y() > 200) {// lets some coins bounce
+ physic.set_velocity_y(-99);
+ }else{
+ physic.set_velocity_y(0);
+ physic.set_velocity_x(0);
+ }
+ }
+ if(hit.right || hit.left) {
+ if(physic.get_velocity_x() > clink_threshold || physic.get_velocity_x() < clink_threshold)
+ SoundManager::current()->play("sounds/coin2.ogg");
+ physic.set_velocity_x(-physic.get_velocity_x());
+ }
+ if(hit.top) {
+ if(physic.get_velocity_y() < clink_threshold)
+ SoundManager::current()->play("sounds/coin2.ogg");
+ physic.set_velocity_y(-physic.get_velocity_y());
+ }
+}
+