added object remove_listener so that you can get a message if some objects are remove...
[supertux.git] / src / object / gameobjs.cpp
index 3201eb2..bce0f21 100644 (file)
@@ -146,289 +146,6 @@ FloatingText::draw(DrawingContext& context)
   context.pop_transform();
 }
 
-/* Trampoline */
-
-#if 0
-Sprite *img_trampoline;
-
-Trampoline::Trampoline(LispReader& reader)
-{
-  reader.read_float("x", base.x);
-  reader.read_float("y", base.y); 
-  base.width = 32;
-  base.height = 32;
-  power = 7.5;
-  reader.read_float("power", power);
-
-  frame = 0;
-  mode = M_NORMAL;
-  physic.reset();
-}
-
-Trampoline::Trampoline(float x, float y)
-{
-  base.x = x;
-  base.y = y;
-  base.width = 32;
-  base.height = 32;
-  power = 7.5;
-
-  frame = 0;
-  mode = M_NORMAL;
-  physic.reset();
-}
-
-void
-Trampoline::write(LispWriter& writer)
-{
-  writer.start_list("trampoline");
-
-  writer.write_float("x", base.x);
-  writer.write_float("y", base.y);
-  writer.write_float("power", power);
-
-  writer.end_list("trampoline");
-}
-
-void
-Trampoline::draw(DrawingContext& context)
-{
-  img_trampoline->set_frame(frame);
-  img_trampoline->draw(context, base, LAYER_OBJECTS);
-  frame = 0;
-}
-
-void
-Trampoline::action(float frame_ratio)
-{
-  // TODO: Remove if we're too far off the screen
-
-  // Falling
-  if (mode != M_HELD)
-  {
-    if (issolid(base.x + base.width/2, base.y + base.height))
-    {
-      base.y = int((base.y + base.height)/32) * 32 - base.height;
-
-      physic.enable_gravity(false);
-      physic.set_velocity_y(0.0f);
-
-      physic.set_velocity_x(0);
-    }
-    else
-    {
-      physic.enable_gravity(true);
-    }
-  }
-  else // Player is carrying us around
-  {
-    /* FIXME: The trampoline object shouldn't know about pplayer objects. */
-    /* If we're holding the iceblock */
-    Player& tux = *Sector::current()->player;
-    Direction dir = tux.dir;
-
-    if(dir == RIGHT)
-    {
-      base.x = tux.base.x + 16;
-      base.y = tux.base.y + tux.base.height/1.5 - base.height;
-    }
-    else /* facing left */
-    {
-      base.x = tux.base.x - 16;
-      base.y = tux.base.y + tux.base.height/1.5 - base.height;
-    }
-
-    if(collision_object_map(base))
-    {
-      base.x = tux.base.x;
-      base.y = tux.base.y + tux.base.height/1.5 - base.height;
-    }
-  }
-
-  physic.apply(frame_ratio, base.x, base.y, Sector::current()->gravity);
-  collision_swept_object_map(&old_base, &base);
-}
-
-void
-Trampoline::collision(const MovingObject&, int)
-{
-  // comes later
-}
-
-void
-Trampoline::collision(void *p_c_object, int c_object, CollisionType type)
-{
-  Player* pplayer_c = NULL;
-  switch (c_object)
-  {
-    case CO_PLAYER:
-      pplayer_c = (Player*) p_c_object;
-
-      if (type == COLLISION_NORMAL)
-      {
-        // Pick up if HELD (done in Player)
-      }
-
-      else if (type == COLLISION_SQUISH)
-      {
-        int squish_amount = (32 - (int)pplayer_c->base.y % 32);
-
-        if (squish_amount < 24)
-          frame = 3;
-        else if (squish_amount < 28)
-          frame = 2;
-        else if (squish_amount < 30)
-          frame = 1;
-        else
-          frame = 0;
-
-        if (squish_amount < 20) {
-          pplayer_c->physic.set_velocity_y(power);
-          pplayer_c->fall_mode = Player::TRAMPOLINE_JUMP;
-        }
-        else if (pplayer_c->physic.get_velocity_y() < 0)
-          pplayer_c->physic.set_velocity_y(-squish_amount/32);
-      }
-
-      break;
-
-    default:
-      break;
-    
-  }
-}
-#endif
-
-/* Flying Platform */
-
-#if 0
-Sprite *img_flying_platform;
-
-FlyingPlatform::FlyingPlatform(LispReader& reader)
-{
-  reader.read_int_vector("x", pos_x);
-  reader.read_int_vector("y", pos_y);
-
-  velocity = 2.0;
-  reader.read_float("velocity", velocity);
-
-  base.x = pos_x[0];
-  base.y = pos_y[0];
-  base.width = 96;
-  base.height = 40;
-
-  point = 0;
-  move = false;
-
-  float x = pos_x[point+1] - pos_x[point];
-  float y = pos_y[point+1] - pos_y[point];
-  vel_x = x*velocity / sqrt(x*x + y*y);
-  vel_y = -(velocity - vel_x);
-
-  frame = 0;
-}
-
-FlyingPlatform::FlyingPlatform(int x, int y)
-{
-base.x = x;
-base.y = y;
-point = 0;
-move = false;
-}
-
-void
-FlyingPlatform::write(LispWriter& writer)
-{
-  writer.start_list("flying-trampoline");
-
-  writer.write_int_vector("x", pos_x);
-  writer.write_int_vector("y", pos_y);
-  writer.write_float("velocity", velocity);
-
-  writer.end_list("flying-trampoline");
-}
-
-void
-FlyingPlatform::draw(DrawingContext& context)
-{
-  img_flying_platform->draw(context, base, LAYER_OBJECTS);
-}
-
-void
-FlyingPlatform::action(float frame_ratio)
-{
-  // TODO: Remove if we're too far off the screen
-
-if(!move)
-  return;
-
-if((unsigned)point+1 != pos_x.size())
-  {
-  if(((pos_x[point+1] > pos_x[point] && base.x >= pos_x[point+1]) ||
-      (pos_x[point+1] < pos_x[point] && base.x <= pos_x[point+1]) ||
-      pos_x[point] == pos_x[point+1]) &&
-    ((pos_y[point+1] > pos_y[point] && base.y >= pos_y[point+1]) ||
-      (pos_y[point+1] < pos_y[point] && base.y <= pos_y[point+1]) ||
-      pos_y[point] == pos_y[point+1]))
-    {
-    point++;
-
-    float x = pos_x[point+1] - pos_x[point];
-    float y = pos_y[point+1] - pos_y[point];
-    vel_x = x*velocity / sqrt(x*x + y*y);
-    vel_y = -(velocity - vel_x);
-    }
-  }
-else   // last point
-  {
-  // point = 0;
-  // reverse vector
-  return;
-  }
-/*
-if(pos_x[point+1] > base.x)
-  base.x += velocity * frame_ratio;
-else if(pos_x[point+1] < base.x)
-  base.x -= velocity * frame_ratio;
-
-if(pos_y[point+1] > base.y)
-  base.y += velocity * frame_ratio;
-else if(pos_y[point+1] < base.y)
-  base.y -= velocity * frame_ratio;
-*/
-
-base.x += vel_x * frame_ratio;
-base.y += vel_y * frame_ratio;
-}
-
-void
-FlyingPlatform::collision(const MovingObject&, int)
-{
-  // comes later
-}
-
-void
-FlyingPlatform::collision(void *p_c_object, int c_object, CollisionType type)
-{
-(void) p_c_object;
-(void) type;
-
-//  Player* pplayer_c = NULL;
-  switch (c_object)
-  {
-    case CO_PLAYER:
-//      pplayer_c = (Player*) p_c_object;
-      move = true;
-
-      break;
-
-    default:
-      break;
-    
-  }
-}
-#endif
-
 Sprite *img_smoke_cloud = 0;
 
 SmokeCloud::SmokeCloud(const Vector& pos)