/[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.63 by reallysoft, Mon Jul 14 22:24:05 2003 UTC revision 1.64 by dheck, Thu Jul 17 20:24:13 2003 UTC
# Line 818  handle_stone_contact(V2 normal, StoneCon Line 818  handle_stone_contact(V2 normal, StoneCon
818      return normal;      return normal;
819  }  }
820    
 static V2  
 reflect(V2 v, V2 normal)  
 {  
     double n = length(normal);  
     if (n != 0)  
         normal /= n;  
     return V2(v-2*(v*normal)*normal);  
 }  
   
821  static void  static void
822  handle_contacts(Actor *a)  handle_contacts(Actor *a)
823  {  {
824        ActorInfo &a1 = *a->get_actorinfo();
825    
826      /*      /*
827      ** Handle contacts with stones      ** Handle contacts with stones
828      */      */
829      StoneContactList cl;      StoneContactList cl;
830      find_stone_contacts(a, cl);      find_stone_contacts(a, cl);
831      V2 normal = accumulate(cl.begin(), cl.end(), V2(), handle_stone_contact);      if (!cl.empty()) {
832            V2 normal = accumulate(cl.begin(), cl.end(), V2(), handle_stone_contact);
     ActorInfo &a1 = *a->get_actorinfo();  
833    
834      a1.vel = reflect(a1.vel, normal);          double n = length(normal);
835            if (n != 0) {
836                double restitution = 0.8;
837                normal /= n;
838                a1.vel -= (1 + restitution)*(a1.vel*normal)*normal;
839            }
840        }
841    
842      /*      /*
843      ** Handle contacts with other actors      ** Handle contacts with other actors

Legend:
Removed from v.1.63  
changed lines
  Added in v.1.64

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