diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-05-07 14:13:46 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-05-07 14:13:46 (GMT) |
commit | 530c0b4f4632c36dd4805325abad7d45ed32f5c0 (patch) | |
tree | 39b33905cd5e95e1bffe50c4137030e1cda66cab /grid.py | |
parent | 87a534dda76b186f695717689d0fdca834920a78 (diff) |
most of a fix for #3568
Diffstat (limited to 'grid.py')
-rw-r--r-- | grid.py | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -187,10 +187,26 @@ class Grid: ''' Convert from sprite x,y to match index. ''' return int((pos[1] - self.top) / self.yinc) + def xy_in_match(self, pos): + ''' Is a position at one of the match points? ''' + for i in range(3): + x, y = self.match_to_xy(i) + if pos[0] == x and pos[1] == y: + return True + return False + def match_to_xy(self, i): ''' Convert from match index to x, y position. ''' return ((MATCH_POSITION, self.top + i * self.yinc)) + def xy_in_grid(self, pos): + ''' Is a position at one of the grid points? ''' + for i in range(ROW * COL): + x, y = self.grid_to_xy(i) + if pos[0] == x and pos[1] == y: + return True + return False + def xy_to_grid(self, pos): ''' Convert from sprite x,y to grid index. ''' return COL * int((pos[1] - self.top) / self.yinc)\ |