Advertisement
Guest User

Untitled

a guest
Jun 19th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. def get_path(source,destination):
  2. """
  3. Obtain and return a list of the coordinates of all tiles between two points.
  4. """
  5. values = []
  6. (x0,y0) = source
  7. (x1,y1) = destination
  8. dx = x1 - x0
  9. dy = y1 - y0
  10. gradiant = float(dy)/dx
  11. error = 0
  12. y = y0
  13. for x in xrange(x0,x1+1):
  14. values.append((x,y))
  15. error += gradiant
  16. while error > 1 or error < 1:
  17. y +=1
  18. error -=1
  19. values.append((x,y))
  20. if error >= 0.5 or error <= -0.5:
  21. y +=1
  22. error -=1
  23. return values
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement