Mercurial > rinkhals
diff gamelib/animal.py @ 431:129de5883524
Moved intermediate position generation to a more suitable location.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 21 Nov 2009 16:46:12 +0000 |
parents | 42777630956a |
children | 95b81e917399 |
line wrap: on
line diff
--- a/gamelib/animal.py Sat Nov 21 16:43:03 2009 +0000 +++ b/gamelib/animal.py Sat Nov 21 16:46:12 2009 +0000 @@ -3,7 +3,6 @@ import random from pgu.vid import Sprite -from pgu.algo import getline import imagecache import tiles @@ -355,18 +354,7 @@ def _gen_path(self, start_pos, final_pos): """Construct a direct path from start_pos to final_pos, excluding start_pos""" - if abs(start_pos.x - final_pos.x) < 2 and \ - abs(start_pos.y - final_pos.y) < 2: - # pgu gets this case wrong on occasion. - return [final_pos] - start = start_pos.to_tile_tuple() - end = final_pos.to_tile_tuple() - points = getline(start, end) - points.remove(start) # exclude start_pos - if end not in points: - # Rounding errors in getline cause this - points.append(end) - return [Position(x[0], x[1]) for x in points] + return start_pos.intermediate_positions(final_pos) def _find_best_path_step(self, final_pos, gameboard): """Find the cheapest path to final_pos, and return the next step