/[enigma]/enigma/src/items.cc
ViewVC logotype

Diff of /enigma/src/items.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dheck, Sun Jan 5 19:56:39 2003 UTC revision 1.2 by dheck, Tue Jan 7 00:32:05 2003 UTC
# Line 806  namespace Line 806  namespace
806      private:      private:
807          V3 get_force(Actor *a, V3 x, V3 v, double time)          V3 get_force(Actor *a, V3 x, V3 v, double time)
808          {          {
809              V3 dv = center - x;              V3 b = 1.5*(center - x);
810              double dist = length(dv);              double bb = length(b);
811  //             if (dist > 10 || dist < 0.1)              if (bb > 0) {
812  //                 return V3();                  return 30*b/(bb*bb);
813  //             else              }
814  //                 return strength * dv/(dist*dist);              return V3();
             double r0=0.5;  
             if (dist < r0)  
                 return 50*dv;  
             else  
                 return (dv/dist)*25*pow(dist-r0+2, -0.5);  
815          }          }
816    
817          V3 center;          V3 center;
# Line 827  namespace Line 822  namespace
822      {      {
823          CLONEOBJ(WormHole);          CLONEOBJ(WormHole);
824      public:      public:
825          WormHole() : Item("it-wormhole"), state(IDLE), actor(0) {          WormHole() : Item("it-wormhole") {
826              set_attrib("targetx", 9.5);              set_attrib("targetx", 9.5);
827              set_attrib("targety", 9.5);              set_attrib("targety", 9.5);
828          }          }
# Line 843  namespace Line 838  namespace
838              Item::on_removal();              Item::on_removal();
839          }          }
840    
841          bool actor_hit(Actor *a)          bool actor_hit(Actor *a);
         {  
             if (state == IDLE && near_center_p(a)) {  
                 {  
                     //if (world::YieldActor(a) == a)  
 //                     world::GrabActor(a);  
                     actor = a;  
                     state = WARPING;  
                     AddSprite(display::SPRITE_EFFECT, get_center(), "ring-anim");  
 //                     g_timer.set_alarm(this, 0.2, false);  
                 }  
             }  
             return false;  
         }  
   
         void alarm() {  
             assert(state == WARPING);  
 //             double x = double_attrib("targetx");  
 //             double y = double_attrib("targety");  
 //             world::AddActor(x, y, actor);  
             world::ReleaseActor(actor);  
             state = IDLE;  
             actor = 0;  
         }  
842    
843          V3 get_center() const {          V3 get_center() const {
844              GridPos p = get_pos();              GridPos p = get_pos();
# Line 879  namespace Line 851  namespace
851          }          }
852                    
853          // Variables.          // Variables.
         enum State { IDLE, WARPING } state;  
         Actor *actor;           // The actor being warped (if any)  
   
854          WormHole_FF ff;          WormHole_FF ff;
855      };      };
856  }  }
857    
858    bool
859    WormHole::actor_hit(Actor *actor)
860    {
861        if (near_center_p(actor)) {
862            AddSprite(display::SPRITE_EFFECT, get_center(), "ring-anim");
863            double x, y;
864            if (double_attrib("targetx", &x) && double_attrib("targety", &y)) {
865                world::WarpActor(actor, x, y);
866            }
867        }
868        return false;
869    }
870    
871    
872  //----------------------------------------  //----------------------------------------
873  // YinYang item  // YinYang item
874  //----------------------------------------  //----------------------------------------

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26