Commits

makestory committed 81aad62

distance consider across edge

Comments (0)

Files changed (1)

examples/makestory/musashi.rb

 end
 
 def distance(from,to)
-  (from[0] - to[0]).abs + (from[1] - to[1]).abs
+  sub_x = (from[0] - to[0]).abs
+  sub_y = (from[1] - to[1]).abs
+  (sub_x > @map['size'][0]/2 ? @map['size'][0] - sub_x : sub_x) + (sub_y > @map['size'][1]/2 ? @map['size'][1] - sub_y : sub_y) 
 end
 
 def info