- #print " posObstacle: $posObstacle". \r
- \r
- obsLoc::y=y=posObstacle::y. \r
- \r
- if (dot((i get-direction),(1,0,0))):\r
- {\r
- obsLoc::x=x=((self get-location)::x + ((posObstacle::z - (self get-location)::z)*v::x/v::z)).\r
- obsLoc::z=z=posObstacle::z.\r
- } \r
- else\r
- {\r
- obsLoc::z=z=((self get-location)::z + ((posObstacle::x - (self get-location)::x)*v::z/v::x)).\r
- obsLoc::x=x=posObstacle::x.\r
- } \r
-\r
- #Dibujo el laser\r
- \r
- draw set-color to (1, 0, 0).\r
- draw draw-line from (self get-location) to obsLoc.\r
- }\r
+ #print " posObstacle: $posObstacle". \r
+ \r
+ dist=|obsLoc - (self get-location)|.\r
+ if( (j==0) || (min>dist) ):\r
+ {\r
+ min=dist.\r
+ obs=obsLoc.\r
+ j++. \r
+ }\r
+\r
+ } \r
+\r