Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_path(source,destination):
- """
- Obtain and return a list of the coordinates of all tiles between two points.
- """
- values = []
- (x0,y0) = source
- (x1,y1) = destination
- dx = x1 - x0
- dy = y1 - y0
- gradiant = float(dy)/dx
- error = 0
- y = y0
- for x in xrange(x0,x1+1):
- values.append((x,y))
- error += gradiant
- while error > 1 or error < 1:
- y +=1
- error -=1
- values.append((x,y))
- if error >= 0.5 or error <= -0.5:
- y +=1
- error -=1
- return values
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement