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

Diff of /enigma/src/world.cc

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

revision 1.16 by dheck, Thu Mar 13 18:07:39 2003 UTC revision 1.17 by dheck, Sun Mar 23 17:34:37 2003 UTC
# Line 40  using namespace std; Line 40  using namespace std;
40  using namespace world;  using namespace world;
41  using namespace px;  using namespace px;
42    
 namespace test  
 {  
     enum ShapeType  
     {  
         SHAPE_Sphere,  
         SHAPE_Square,  
         SHAPE_Rectangle,  
         SHAPE_Polygon,  
     };  
   
     class Shape  
     {  
         ShapeType type;  
     public:  
         Shape (ShapeType t) : type(t) {}  
         virtual ~Shape() {}  
   
         ShapeType get_type() const { return type; }  
     };  
   
     struct Sphere : public Shape  
     {  
         Sphere (const V2 &c, double r)  
             : Shape(SHAPE_Sphere), center(c), radius(r)  
         {}  
   
         // Variables.  
         V2 center;  
         double radius;  
     };  
 }  
   
 //----------------------------------------  
 // Sphere  
 //----------------------------------------  
 namespace  
 {  
     class Sphere {  
         V2 center;  
         double radius;  
     public:  
         Sphere(const V2 &c, double r)  
             : center(c), radius(r)  
         {}  
         bool contains(const V2 &p) const {  
             return length(center-p) < radius;  
         }  
         bool intersection_point(const Sphere &s, V2 &ip) {  
             double rr = radius + s.radius;  
             ip = center + normalize(s.center-center)*rr/2;  
             return (length(center - s.center) <= rr);  
         }  
     };  
 }  
   
43  //----------------------------------------  //----------------------------------------
44  // Rubber band  // Rubber band
45  //----------------------------------------  //----------------------------------------
# Line 125  namespace world Line 70  namespace world
70  }  }
71    
72  RubberBand::RubberBand (Actor *a1, Actor *a2, double strength_, double length_)  RubberBand::RubberBand (Actor *a1, Actor *a2, double strength_, double length_)
73  : actor(a1), actor2(a2), stone(0), model(),  : actor(a1), actor2(a2), stone(0),
74      model(display::AddRubber(get_p1(),get_p2())),
75    strength(strength_), length(length_)    strength(strength_), length(length_)
76  {  {
77      assert(actor);      assert(actor);
78      assert(length >= 0);      assert(length >= 0);
     model = display::AddRubber(get_p1(),get_p2());  
79  }  }
80    
81  RubberBand::RubberBand (Actor *a1, Stone *st, double strength_, double length_)  RubberBand::RubberBand (Actor *a1, Stone *st, double strength_, double length_)
82  : actor(a1), actor2(0), stone(st), model(0)  : actor(a1), actor2(0), stone(st), model(0),
83  , strength(strength_), length(length_)    strength(strength_), length(length_)
84  {  {
85      assert(actor);      assert(actor);
86      assert(length >= 0);      assert(length >= 0);
# Line 771  world::Load(const string &name) Line 716  world::Load(const string &name)
716          clear_world();          clear_world();
717          return false;          return false;
718      }      }
719    
720        InitWorld();
721        return true;
722    }
723    
724    void
725    world::InitWorld()
726    {
727      laser::RecalcLight();      laser::RecalcLight();
728      laser::RecalcLightNow(); // recalculate laser beams if necessary      laser::RecalcLightNow(); // recalculate laser beams if necessary
729    
# Line 783  world::Load(const string &name) Line 736  world::Load(const string &name)
736              player::AddActor(iplayer,a);              player::AddActor(iplayer,a);
737          }          }
738      }      }
   
     return true;  
739  }  }
740    
741  void  void

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

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